Open roj516 opened 6 months ago
So I'm not sure if we'll be able to address this for 2 reasons:
1) The special feature of a raw NamedTuple
“pseudo-class” that mypy has for NamedTuple
has the comment "Note that this behavior is highly experimental, non-standard, and may not be supported by other type checkers and IDEs."
2) The python typing system doesn't really support having a subclass of NamedTuple
with undefined fields, which is what we would need to return in this case.
From a static typing perspective, we know we are returning a kind of "generic" named tuple, but we don't know what the fields are, since it has to work for any DataFrame
Describe the bug
Code that passed the output of itertuples to functions expecting
NamedTuple
fails in mypy withincompatible type "_PandasNamedTuple"; expected "NamedTuple"
(Maybe related to the fix for issue #834)To Reproduce
Please complete the following information:
pandas-stubs
: 2.2.0.240218Additional context mypy has special casing for NamedTuple - https://mypy.readthedocs.io/en/latest/kinds_of_types.html#named-tuples