python-attrs / python-attrs/attrs
Typing not working properly when positional argument is defined in subclass with redefined kwargs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
Describe the bug
Using pyright for type checking produces the following errors:
from attrs import define
@define
class A:
foo: int
bar: str = "baz"
@define
class B(A):
zoo: float
bar: str = "zaz"
b = B(1, 2.7)
print(b)
>>> B(foo=1, zoo=2.7, bar='zaz')


Not sure whether the problem is with attrs type definitions or with pyright, so will create issues in both places.
Perhaps types are not defined properly somewhere?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided attrs example with pyright and confirm which call-site errors occur for the subclass constructor. Then inspect whether attrs' typing definitions or pyright's handling of redefined kwargs is responsible; done means the responsible project is identified and the example type-checks correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100