python-attrs / python-attrs/attrs

Type annotation for attr.ib wrappers functions

Open
#779 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Typing
Dominant language
Python
Stars
5.8k
Forks
480
Avg merge
2h 15m
Merged PRs (30d)
2

Description

It's possible to type a method that wraps an attr.ib attribute?

Example:

import attr
from typing import Any

def typed() -> Any:
    return attr.ib(type=str)

@attr.s
class TestingParams:
    foo = attr.ib(type=str)
    acme = typed()

TestingParams(foo='1', acme='3')

Executing mypy (0.812) with Python (3.7.3) and attrs (20.3.0) I got the following output

error: Unexpected keyword argument "acme" for "TestingParams"  [call-arg]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example with mypy 0.812, Python 3.7.3, and attrs 20.3.0, focusing on the unexpected keyword argument for the wrapped attribute. Then inspect the attrs typing integration and determine what support is needed; done means the example type-checks without the acme error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.