Skip to content

Vendor typing._SpecialForm to fool typing._type_check - #966

Merged
JelleZijlstra merged 4 commits into
python:masterfrom
CharString:issue_964
Nov 29, 2021
Merged

Vendor typing._SpecialForm to fool typing._type_check#966
JelleZijlstra merged 4 commits into
python:masterfrom
CharString:issue_964

Conversation

@CharString

Copy link
Copy Markdown
Contributor

Adds a local copy of _SpecialForm in our namespace, so
typing._type_check won't raise TypeError. (#964)

@JelleZijlstra

Copy link
Copy Markdown
Member

This has severe merge conflicts because we just renamed src_py3 to src, could you rebase?

@CharString

Copy link
Copy Markdown
Contributor Author

:) I was looking into that.

Adds a local copy of _SpecialForm in our namespace, so
typing._type_check won't raise TypeError. (#964)
Comment thread typing_extensions/src/typing_extensions.py Outdated
Chris Wesseling and others added 2 commits November 26, 2021 21:04
Co-authored-by: James Hilton-Balfe <50501825+Gobot1234@users.noreply.github.com>
TypeGuard = _TypeGuard(_root=True)

if not hasattr(typing, "Self") and sys.version_info[:2] >= (3, 7):
# Vendored from cpython typing._SpecialFrom

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's a bit hard to follow the if chains here, but can't this just be together with the appropriate branch for 3.7-3.10 so we don't have to duplicate the conditions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I refactor the uses of typing._SpecialForm to use this vendored verion too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's change Self only for simplicity.

@JelleZijlstra
JelleZijlstra merged commit 0c8e55f into python:master Nov 29, 2021
srittau pushed a commit to srittau/typing that referenced this pull request Dec 2, 2021
Adds a local copy of _SpecialForm in our namespace, so
typing._type_check won't raise TypeError. (#964)

Co-authored-by: James Hilton-Balfe <50501825+Gobot1234@users.noreply.github.com>
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.

4 participants