KEMBAR78
Fix meet for tuple with instance by ilevkivskyi · Pull Request #5641 · python/mypy · GitHub
Skip to content

Conversation

@ilevkivskyi
Copy link
Member

Fixes #5640

Since generic tuple types are not supported, map_instance_to_supertype is not needed here. This solution doesn't work for general multiple inheritance, for example the test case will not work with if isinstance(o, BaseTuple), but this is exactly the same as for e.g. two instance types.

Copy link
Collaborator

@JukkaL JukkaL 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, I only have one comment.

mypy/meet.py Outdated
elif is_proper_subtype(t, self.s):
# A named tuple that inherits from a normal class
return t
elif (isinstance(self.s, Instance) and t.fallback.type == self.s.type):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the condition can never be true. Either move this to the above elif block or remove?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good catch, I think this is not needed anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, fixed now!

@ilevkivskyi ilevkivskyi merged commit a89aec5 into python:master Sep 19, 2018
@ilevkivskyi ilevkivskyi deleted the tuple-regression branch September 19, 2018 20:00
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.

2 participants