Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5591,7 +5591,7 @@ def visit_type_alias_stmt(self, s: TypeAliasStmt) -> None:
self.msg.unimported_type_becomes_any("Type alias target", res, s)
res = make_any_non_unimported(res)
eager = self.is_func_scope()
if isinstance(res, ProperType) and isinstance(res, Instance) and not res.args:
if isinstance(res, ProperType) and isinstance(res, Instance):
fix_instance(res, self.fail, self.note, disallow_any=False, options=self.options)
alias_node = TypeAlias(
res,
Expand Down
21 changes: 20 additions & 1 deletion test-data/unit/check-python313.test
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def func_a1(
reveal_type(b) # N: Revealed type is "builtins.dict[builtins.float, builtins.str]"
reveal_type(c) # N: Revealed type is "builtins.dict[builtins.float, builtins.float]"
reveal_type(d) # N: Revealed type is "builtins.dict[builtins.int, builtins.str]"
[builtins fixtures/tuple.pyi]
[builtins fixtures/dict.pyi]
[typing fixtures/typing-full.pyi]

[case testPEP695TypeParameterDefaultTypeAlias2]
Expand Down Expand Up @@ -255,3 +255,22 @@ def func_c1(

[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]

[case testPEP695TypeParameterDefaultTypeAlias4]
# flags: --disallow-any-generics
class A[L = int, M = str]: ...
TD1 = A[float]
type TD2 = A[float]

def func_d1(
a: TD1,
b: TD1[float], # E: Bad number of arguments for type alias, expected 0, given 1
c: TD2,
d: TD2[float], # E: Bad number of arguments for type alias, expected 0, given 1
) -> None:
reveal_type(a) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
reveal_type(b) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
reveal_type(c) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
reveal_type(d) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]