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

Fix TypeIs narrowing to NewType by nightcityblade · Pull Request #22179 · python/mypy · GitHub

Repository navigation

Fix TypeIs narrowing to NewType - #22179

Open
nightcityblade wants to merge 1 commit into
python:masterfrom
nightcityblade:fix/issue-22175
Open

nightcityblade wants to merge 1 commit into
python:masterfrom
nightcityblade:fix/issue-22175

Conversation

Copy link
Copy Markdown

Fixes #22175

Preserve NewType targets when narrowing through TypeIs. Runtime isinstance checks still erase NewType to its base because they cannot distinguish the wrapper, while an explicit TypeIs predicate can now narrow to the declared NewType.

Adds regression coverage for both the positive and negative branches.

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeIs doesn't narrow a NewType

1 participant


Back | FazBrowse Home | New Git URL