Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JukkaL committed May 15, 2024
1 parent 2c7e147 commit ef1b473
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ def ast3_parse(

if sys.version_info >= (3, 12):
ast_TypeAlias = ast3.TypeAlias
ParamSpec = ast3.ParamSpec
TypeVarTuple = ast3.TypeVarTuple
ast_ParamSpec = ast3.ParamSpec
ast_TypeVarTuple = ast3.TypeVarTuple
else:
ast_TypeAlias = Any
ParamSpec = Any
TypeVarTuple = Any
ast_ParamSpec = Any
ast_TypeVarTuple = Any

N = TypeVar("N", bound=Node)

Expand Down Expand Up @@ -1179,9 +1179,9 @@ def translate_type_params(self, type_params: list[Any]) -> list[TypeParam]:
for p in type_params:
bound = None
values: list[Type] = []
if isinstance(p, ParamSpec): # type: ignore[misc]
if isinstance(p, ast_ParamSpec): # type: ignore[misc]
explicit_type_params.append(TypeParam(p.name, PARAM_SPEC_KIND, None, []))
elif isinstance(p, TypeVarTuple): # type: ignore[misc]
elif isinstance(p, ast_TypeVarTuple): # type: ignore[misc]
explicit_type_params.append(TypeParam(p.name, TYPE_VAR_TUPLE_KIND, None, []))
else:
if isinstance(p.bound, ast3.Tuple):
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ reveal_type(c.ident(1)) # N: Revealed type is "builtins.int"
# flags: --enable-incomplete-feature=NewGenericSyntax

class C[T]:
def m[S](self, x: S) -> T: ...
def m[S](self, x: S) -> T | S: ...

a: C[int] = C[object]() # E: Incompatible types in assignment (expression has type "C[object]", variable has type "C[int]")
b: C[object] = C[int]()

reveal_type(C[str]().m(1)) # N: Revealed type is "builtins.str"
reveal_type(C[str]().m(1)) # N: Revealed type is "Union[builtins.str, builtins.int]"

[case testPEP695InferVarianceSimpleFromMethod]
# flags: --enable-incomplete-feature=NewGenericSyntax
Expand Down

0 comments on commit ef1b473

Please sign in to comment.