-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two issues with subclassing namedtuple-generated class and overriding __new__ #1279
Comments
Yeah, mypy should probably define NamedTuple in terms of |
In particular #1021 looks like a dependency for this. (And we haven't assigned that a milestone yet, so we can't assign a milestone here either.) |
I propose to bump the priority here. This seems a real problem to some of our users. |
Sure, although TBH this will not help much, we are already overloaded with work. |
Indeed. :-( And aggressively critical users don't motivate me. |
The __new__ method should suffice, and having both interferes with providing a __new__ in namedtuples, which we want to do to fix python/mypy#1279.
I don't think python/typeshed#2467 actually fixed this (the auto fix triggered by accident). |
Oops, sorry for that and thanks for fixing. |
The __new__ method should suffice, and having both interferes with providing a __new__ in namedtuples, which we want to do to fix python/mypy#1279.
Python 3.5.1, mypy 2f89c79.
Test code:
Python result:
mypy output:
I poked around in the code a bit and I believe I managed to narrow this down to the following difference:
__new__
defined (CPython: https://github.com/python/cpython/blob/9967d6c1053f186f3b3d118ac336a03752efec32/Lib/collections/__init__.py#L316)__init__
instead (mypy/mypy/semanal.py
Line 1444 in 2f89c79
The text was updated successfully, but these errors were encountered: