diff --git a/mypy/typeops.py b/mypy/typeops.py index 4fe187f811ca..036d782be89c 100644 --- a/mypy/typeops.py +++ b/mypy/typeops.py @@ -310,12 +310,14 @@ class B(A): pass if not func.arg_types: # Invalid method, return something. return cast(F, func) - if func.arg_kinds[0] == ARG_STAR: + if func.arg_kinds[0] in (ARG_STAR, ARG_STAR2): # The signature is of the form 'def foo(*args, ...)'. # In this case we shouldn't drop the first arg, # since func will be absorbed by the *args. - # TODO: infer bounds on the type of *args? + + # In the case of **kwargs we should probably emit an error, but + # for now we simply skip it, to avoid crashes down the line. return cast(F, func) self_param_type = get_proper_type(func.arg_types[0]) diff --git a/test-data/unit/check-typeddict.test b/test-data/unit/check-typeddict.test index bfc7b6394d52..dc1929751977 100644 --- a/test-data/unit/check-typeddict.test +++ b/test-data/unit/check-typeddict.test @@ -3579,6 +3579,24 @@ class Test: run(test2, other=0, **params) # E: Argument "other" to "run" has incompatible type "int"; expected "str" [builtins fixtures/tuple.pyi] +[case testTypedDictUnpackSingleWithSubtypingNoCrash] +from typing import Callable +from typing_extensions import TypedDict, Unpack + +class Kwargs(TypedDict): + name: str + +def f(**kwargs: Unpack[Kwargs]) -> None: + pass + +class C: + d: Callable[[Unpack[Kwargs]], None] + +# TODO: it is an old question whether we should allow this, for now simply don't crash. +class D(C): + d = f +[builtins fixtures/tuple.pyi] + [case testTypedDictInlineNoOldStyleAlias] # flags: --enable-incomplete-feature=InlineTypedDict X = {"int": int, "str": str}