Skip to content

Don't narrow Type[X] with a metaclass #10424

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

Merged
merged 1 commit into from
May 5, 2021
Merged

Don't narrow Type[X] with a metaclass #10424

merged 1 commit into from
May 5, 2021

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 5, 2021

We could narrow Type[T] to <nothing> when tested against a
metaclass, which is not useful. Now we don't do any narrowing
in this case.

Fixes #10423.

We could narrow `Type[T]` to `<nothing>` when tested against a
metaclass, which is not useful. Now we don't do any narrowing
in this case.

Fixes #10423.
@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2021

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

sphinx (https://github.com/sphinx-doc/sphinx.git)
+ sphinx/util/typing.py:226: error: unused 'type: ignore' comment
+ sphinx/util/typing.py:227: error: unused 'type: ignore' comment
+ sphinx/util/typing.py:228: error: unused 'type: ignore' comment
+ sphinx/util/typing.py:229: error: unused 'type: ignore' comment
+ sphinx/util/typing.py:231: error: unused 'type: ignore' comment
+ sphinx/util/typing.py:232: error: unused 'type: ignore' comment

@JukkaL JukkaL merged commit 6d2635d into master May 5, 2021
@JukkaL JukkaL deleted the narrow-metaclass branch May 5, 2021 13:15
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.

Narrowing types using a metaclass can cause false positives
2 participants