Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdanal committed Feb 21, 2024
1 parent aaf19dd commit c020b79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,8 @@ def analyze_callable_args(
if self.defining_alias and self.has_type_params:
tvar_likes = self.find_type_var_likes(arg)
for name, tvar_expr in tvar_likes:
if (name, tvar_expr) not in self.allowed_alias_tvars:
tvar_def = self.tvar_scope.get_binding(name)
if tvar_def is None or tvar_def not in self.allowed_alias_tvars:
self.fail(
f'Type variable "{name}" is not included in type_params',
arglist,
Expand Down
4 changes: 4 additions & 0 deletions test-data/unit/check-type-aliases.test
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,13 @@ reveal_type(xi) # N: Revealed type is "builtins.dict[builtins.int, builtins.str

VariadicAlias1 = TypeAliasType("VariadicAlias1", Tuple[Unpack[Ts]], type_params=(Ts,))
VariadicAlias2 = TypeAliasType("VariadicAlias2", Tuple[Unpack[Ts], K], type_params=(Ts, K))
VariadicAlias3 = TypeAliasType("VariadicAlias3", Callable[[Unpack[Ts]], int], type_params=(Ts,))
xv: VariadicAlias1[int, str] = (1, 'a')
yv: VariadicAlias1[str, int] = (1, 'a') # E: Incompatible types in assignment (expression has type "Tuple[int, str]", variable has type "Tuple[str, int]")
zv: VariadicAlias2[int, str] = (1, 'a')
def int_in_int_out(x: int) -> int: return x
wv: VariadicAlias3[int] = int_in_int_out
reveal_type(wv) # N: Revealed type is "def (builtins.int) -> builtins.int"

ParamAlias = TypeAliasType("ParamAlias", Callable[P, int], type_params=(P,))
def f(x: str, y: float) -> int: return 1
Expand Down

0 comments on commit c020b79

Please sign in to comment.