Skip to content

Commit cd16507

Browse files
committed
Fixes to Callable[..., t] types
Closes #393.
1 parent 17f15cb commit cd16507

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

mypy/expandtype.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ def visit_type_var(self, t: TypeVarType) -> Type:
7777

7878
def visit_callable_type(self, t: CallableType) -> Type:
7979
return CallableType(self.expand_types(t.arg_types),
80-
t.arg_kinds,
81-
t.arg_names,
82-
t.ret_type.accept(self),
83-
t.fallback,
84-
t.name,
85-
t.variables,
86-
self.expand_bound_vars(t.bound_vars), t.line)
80+
t.arg_kinds,
81+
t.arg_names,
82+
t.ret_type.accept(self),
83+
t.fallback,
84+
t.name,
85+
t.variables,
86+
self.expand_bound_vars(t.bound_vars),
87+
t.line,
88+
t.is_ellipsis_args)
8789

8890
def visit_overloaded(self, t: Overloaded) -> Type:
8991
items = [] # type: List[CallableType]

mypy/sametypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def visit_callable_type(self, left: CallableType) -> bool:
7474
is_same_types(left.arg_types, cright.arg_types) and
7575
left.arg_names == cright.arg_names and
7676
left.arg_kinds == cright.arg_kinds and
77-
left.is_type_obj() == cright.is_type_obj())
77+
left.is_type_obj() == cright.is_type_obj() and
78+
left.is_ellipsis_args == cright.is_ellipsis_args)
7879
else:
7980
return False
8081

mypy/test/data/check-functions.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ def g4(*, y: int) -> str: pass
822822
f(g1)
823823
f(g2)
824824
f(g3)
825-
f(g4) # E: Argument 1 to "f" has incompatible type Callable[..., str]; expected Callable[..., int]
825+
f(g4) # E: Argument 1 to "f" has incompatible type Callable[[int], str]; expected Callable[..., int]
826826

827827
[case testCallableWithArbitraryArgsSubtypingWithGenericFunc]
828828
from typing import Callable, TypeVar

mypy/types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ def __init__(self, arg_types: List[Type],
257257
name: str = None,
258258
variables: List[TypeVarDef] = None,
259259
bound_vars: List[Tuple[int, Type]] = None,
260-
is_ellipsis_args: bool = False,
261-
line: int = -1) -> None:
260+
line: int = -1,
261+
is_ellipsis_args: bool = False) -> None:
262262
if variables is None:
263263
variables = []
264264
if not bound_vars:
@@ -575,7 +575,8 @@ def visit_callable_type(self, t: CallableType) -> Type:
575575
t.name,
576576
self.translate_variables(t.variables),
577577
self.translate_bound_vars(t.bound_vars),
578-
t.line)
578+
t.line,
579+
t.is_ellipsis_args)
579580

580581
def visit_tuple_type(self, t: TupleType) -> Type:
581582
return TupleType(self.translate_types(t.items),

0 commit comments

Comments
 (0)