Skip to content
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

Prepend bases on first subscription #386

Merged
merged 2 commits into from
Feb 3, 2017

Conversation

ilevkivskyi
Copy link
Member

Fixes #385
Fixes #384

In previous versions of typing, __bases__ on subscription where prepend with __origin__, so that MRO of, e.g., Mapping[int, T][str] was:

[Mapping[int, str], Mapping[int, T], Mapping, collections.abc.Mapping, ...]

This was removed for several reasons. However, now it looks like complete removal of such prepending was too radical, since now e.g. issublcass(Node[int], Node) returns False. I believe such runtime check should be equivalent to issublcass(Node, Node), i.e., True.

Here I propose to fix this by only prepending __bases__ on first subscription, so that, e.g, Mapping[int, T][str].__mro__ will be:

[Mapping[int, str], Mapping, collections.abc.Mapping, ...]

This PR also fixes an ambiguity when using typing ABCs with singledispatch().

@ilevkivskyi ilevkivskyi changed the title Prepend bases Prepend bases on first subscription Feb 3, 2017
@ilevkivskyi
Copy link
Member Author

This will also allow to simplify #375 to only adding tests. So that I would like to merge this now.
@gvanrossum I am mentioning you just in case, so that this will not pass unnoticed.

@ilevkivskyi ilevkivskyi merged commit 1229efb into python:master Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

issubclass(Node[int], Node) returns False. singledispatch and typing.Tuple[x] interaction
2 participants