Constructors in subclasses should have same signature or not? #1305
Unanswered
amacfie-tc
asked this question in
Q&A
Replies: 2 comments
|
Pyright intentionally exempts |
0 replies
|
Yes, the docs here seem wrong, or at least inconsistent with current practice. They do reflect the text of PEP 484: https://peps.python.org/pep-0484/#the-type-of-class-objects. In practice (as Eric also said), type checkers allow incompatible |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The Python docs state¹
Does this only apply to classes that we put as arguments to
Typeor to all classes? On the one hand, subclasses have differing constructor signatures all the time, e.g. dataclasses. On the other hand, without this constraint we can do things like this:which Pyright doesn't find any errors in.
All reactions