on-internet
← Community

Pyright type error when using classic `attrs` library with type comments in Python 3.5

Stack Overflow ·

I am using Python 3.5. Since dataclasses doesn't exist in 3.5, I'm using attrs as an alternative - namely, the classic attr namespace from attrs==22.1.0 (which is the last version that supports 3.5). However, when I write the following (using type comments because 3.5 doesn't support variable annotations): import attr from typing import List @attr.s class Foo: names = attr.ib() # type: List[str] Foo(['James']) I get the Pyright error Expected 0 positional arguments when instantiating Foo. The program raises no errors at runtime. If I switch to a newer Python version (e.g. 3.10) in VS Code, the

Comments

Sign in or sign up to comment and upvote.

No comments yet.