Skip to content

Commit

Permalink
Make any callable compatible with (*args: Any, **kwargs: Any)
Browse files Browse the repository at this point in the history
Resolves python#5876
  • Loading branch information
hauntsaninja committed Sep 27, 2021
1 parent d469295 commit e5250d4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mypy/subtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# import mypy.solve
from mypy.nodes import (
FuncBase, Var, Decorator, OverloadedFuncDef, TypeInfo, CONTRAVARIANT, COVARIANT,

ARG_STAR, ARG_STAR2,
)
from mypy.maptype import map_instance_to_supertype
from mypy.expandtype import expand_type_by_instance
Expand Down Expand Up @@ -893,6 +893,14 @@ def g(x: int) -> int: ...
right_star = right.var_arg()
right_star2 = right.kw_arg()

# Treat "def _(*a: Any, **kw: Any) -> X" similarly to "Callable[..., X]"
if (
right.arg_kinds == [ARG_STAR, ARG_STAR2]
and right_star and isinstance(right_star.typ, AnyType)
and right_star2 and isinstance(right_star2.typ, AnyType)
):
return True

# Match up corresponding arguments and check them for compatibility. In
# every pair (argL, argR) of corresponding arguments from L and R, argL must
# be "more general" than argR if L is to be a subtype of R.
Expand Down

0 comments on commit e5250d4

Please sign in to comment.