Fix missing error when redeclaring type variable in nested generic class#18883
Merged
hauntsaninja merged 2 commits intopython:masterfrom Jun 18, 2025
Merged
Conversation
Collaborator
Author
|
Typing conformance diff for this PR (generics_scoping now passes 🎉): diff --git a/conformance/results/mypy/generics_scoping.toml b/conformance/results/mypy/generics_scoping.toml
index d9be0a0..d588666 100644
--- a/conformance/results/mypy/generics_scoping.toml
+++ b/conformance/results/mypy/generics_scoping.toml
@@ -11,6 +11,7 @@ generics_scoping.py:54: error: Type variable "generics_scoping.S" is unbound [v
generics_scoping.py:54: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class)
generics_scoping.py:54: note: (Hint: Use "S" in function signature to bind "S" inside a function)
generics_scoping.py:65: error: Free type variable expected in Generic[...] [misc]
+generics_scoping.py:75: error: Type variable "T" is bound by an outer class [valid-type]
generics_scoping.py:78: error: Type variable "generics_scoping.T" is unbound [valid-type]
generics_scoping.py:78: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_scoping.py:78: note: (Hint: Use "T" in function signature to bind "T" inside a function)
@@ -25,7 +26,6 @@ generics_scoping.py:96: error: Type variable "generics_scoping.T" is unbound [v
generics_scoping.py:96: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_scoping.py:96: note: (Hint: Use "T" in function signature to bind "T" inside a function)
"""
-conformance_automated = "Fail"
+conformance_automated = "Pass"
errors_diff = """
-Line 75: Expected 1 errors
"""
diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml
index e3a8b6e..7162661 100644
--- a/conformance/results/mypy/version.toml
+++ b/conformance/results/mypy/version.toml
@@ -1,2 +1,2 @@
-version = "mypy 1.16.0+dev.e867132134c7b8046ebae2d6e1fa9fc184b9e9d7"
-test_duration = 4.9
+version = "mypy 1.16.0+dev.dd0f577f1caebfcd944fb247086af6150e6f1b02"
+test_duration = 5.3
|
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10479
Fixes a case where mypy doesn't warn about an inner generic class using a type variable by the same name as an outer generic class if the inner generic class doesn't declare the type variable using
Generic,Protocol, or PEP-695 syntax.