Skip to content

Commit eda2913

Browse files
committed
Better handling for generic aliases
1 parent a0b3773 commit eda2913

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

mypy/types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3988,7 +3988,10 @@ def visit_type_alias_type(self, t: TypeAliasType, /) -> str:
39883988
if t.alias is None:
39893989
return "<alias (unfixed)>"
39903990
if self.reveal_simple_types:
3991-
return t.alias.name
3991+
type_str = t.alias.name
3992+
if t.args:
3993+
type_str += f"[{self.list_str(t.args)}]"
3994+
return type_str
39923995
if not t.is_recursive:
39933996
return get_proper_type(t).accept(self)
39943997
if self.dotted_aliases is None:

test-data/unit/check-flags.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,4 +2759,8 @@ class User(TypedDict):
27592759

27602760
def bar(x: int, **kwargs: Unpack[User]) -> None: ...
27612761
reveal_type(bar) # N: Revealed type is "def (x: int, **kwargs: **TypedDict(User, {'age': int, 'name': str}))"
2762+
2763+
Alias = tuple[T, S]
2764+
x: Alias[int, str]
2765+
reveal_type(x) # N: Revealed type is "Alias[int, str]"
27622766
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)