python-attrs / python-attrs/attrs
self.__attrs_init__ doesn't play well with pylance/pyright
Open
Nobody has claimed this yet.
Pyright
Typing
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
Python version: 3.12.5
attrs version: 23.2.0
pylance version: v2024.10.1
code:
import attrs
@attrs.define
class MyClass:
x: int
def __init__(self, x: int):
self.__attrs_init__(x)
# ^^^^^^^^^^
# Cannot access attribute "__attrs_init__" for class "MyClass*"
# Attribute "__attrs_init__" is unknown Pylance[reportAttributeAccessIssue]
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 with the @attrs.define entry point and reproduce the diagnostic using the shown MyClass example with the listed Python, attrs, and Pylance versions. Done means supported attrs_init usage no longer produces the reported unknown-attribute error in Pylance or Pyright.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100