KEMBAR78
Fully analyze named tuple subclasses in third pass by ilevkivskyi · Pull Request #5644 · python/mypy · GitHub
Skip to content

Conversation

@ilevkivskyi
Copy link
Member

Fixes #5195

The fix is straightforward, previously tuple_type was not analyzed for named tuple subclasses.
I also copy the line number for instance types when transforming them.

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Is there a similar transformation that ought to be done for typeddict_type as well?

@ilevkivskyi
Copy link
Member Author

Is there a similar transformation that ought to be done for typeddict_type as well?

I think no. A subclass of a typed dict is also a typed dict (i.e. it becomes itself a "magic" class), while subclassing a named tuple creates a more "normal" class. But I think it makes sense to add a test just for completeness.

@ilevkivskyi ilevkivskyi merged commit 28b1bfe into python:master Sep 19, 2018
@ilevkivskyi ilevkivskyi deleted the rec-tuple-crash branch September 19, 2018 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recursive subclass of NamedTuple crashes mypy

2 participants