FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Prepend bases on first subscription by ilevkivskyi · Pull Request #386 · python/typing · GitHub

/ typing Public

Prepend bases on first subscription - #386

Merged
ilevkivskyi merged 2 commits into
python:masterfrom
ilevkivskyi:prepend-bases
Feb 3, 2017
Merged

Prepend bases on first subscription#386
ilevkivskyi merged 2 commits into
python:masterfrom
ilevkivskyi:prepend-bases

Conversation

Copy link
Copy Markdown
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 changed the title Prepend bases Prepend bases on first subscription Feb 3, 2017

Copy link
Copy Markdown
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 merged commit 1229efb into python:master Feb 3, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL