Issue 34175: typing.NamedTuple: type-checking error when "index" used as member (original) (raw)
Issue34175
Created on 2018-07-20 21:08 by campkeith, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Messages (4) | ||
---|---|---|
msg322038 - (view) | Author: Keith Campbell (campkeith) | Date: 2018-07-20 21:08 |
Find the test case below: ---- from typing import NamedTuple class Foo(NamedTuple): alpha: int index: int ---- This results in the following error when run through type-checking with mypy: ---- % mypy --version mypy 0.620 % mypy go.py go.py:5: error: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "Callable[[Tuple[int, ...], Any, int, int], int]") ---- When I instantiate this class in the python interpreter, I have no problem accessing the "index" member, so I suspect this is a bug in the type checker. | ||
msg322043 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2018-07-21 00:19 |
> So I suspect this is a bug in the type checker. Perhaps this report should go on the mypy bug tracker rather than the Python language tracker. | ||
msg322045 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2018-07-21 00:26 |
> Perhaps this report should go on the mypy bug tracker rather than the Python language tracker. Agreed. It's up to the OP to file an issue there though (hence adding @campkeith back to the nosy list). | ||
msg322120 - (view) | Author: Keith Campbell (campkeith) | Date: 2018-07-21 18:58 |
> It's up to the OP to file an issue there though Will do; thanks! |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:59:03 | admin | set | github: 78356 |
2018-07-21 18:58:56 | campkeith | set | messages: + |
2018-07-21 00:26:59 | gvanrossum | set | status: open -> closednosy: + campkeithmessages: + resolution: third partystage: resolved |
2018-07-21 00:19:48 | rhettinger | set | nosy: + rhettinger, gvanrossum, levkivskyi, - campkeithmessages: + |
2018-07-20 21:08:00 | campkeith | create |