Skip to content

Commit e5250d4

Browse files
author
hauntsaninja
committed
Make any callable compatible with (*args: Any, **kwargs: Any)
Resolves python#5876
1 parent d469295 commit e5250d4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mypy/subtypes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# import mypy.solve
1919
from mypy.nodes import (
2020
FuncBase, Var, Decorator, OverloadedFuncDef, TypeInfo, CONTRAVARIANT, COVARIANT,
21-
21+
ARG_STAR, ARG_STAR2,
2222
)
2323
from mypy.maptype import map_instance_to_supertype
2424
from mypy.expandtype import expand_type_by_instance
@@ -893,6 +893,14 @@ def g(x: int) -> int: ...
893893
right_star = right.var_arg()
894894
right_star2 = right.kw_arg()
895895

896+
# Treat "def _(*a: Any, **kw: Any) -> X" similarly to "Callable[..., X]"
897+
if (
898+
right.arg_kinds == [ARG_STAR, ARG_STAR2]
899+
and right_star and isinstance(right_star.typ, AnyType)
900+
and right_star2 and isinstance(right_star2.typ, AnyType)
901+
):
902+
return True
903+
896904
# Match up corresponding arguments and check them for compatibility. In
897905
# every pair (argL, argR) of corresponding arguments from L and R, argL must
898906
# be "more general" than argR if L is to be a subtype of R.

0 commit comments

Comments
 (0)