-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-pep-695Issues related to PEP 695 syntaxIssues related to PEP 695 syntaxtopic-type-variables
Description
Bug Report
I am unable to use type statements inside a class scope that reference that class' generic types. For example, when trying to declare aliases to generic types.
From my reading of PEP 695, this is allowed usage. It works with pyright but not with mypy.
To Reproduce
class A[T]:
type T2 = T
type OptionalT = T | None
type AT = A[T]
type DictT = dict[str, T]
type ListT = list[T]
Expected Behavior
No errors.
Actual Behavior
main.py:2: error: All type parameters should be declared ("T" not declared) [valid-type]
main.py:3: error: All type parameters should be declared ("T" not declared) [valid-type]
main.py:4: error: All type parameters should be declared ("T" not declared) [valid-type]
main.py:5: error: All type parameters should be declared ("T" not declared) [valid-type]
main.py:6: error: All type parameters should be declared ("T" not declared) [valid-type]
Found 5 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.16.1
- Python version used: 3.13.5
- No parameters, default config file (see above playground link)
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-pep-695Issues related to PEP 695 syntaxIssues related to PEP 695 syntaxtopic-type-variables