Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mypy/typeops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/check-typeddict.test
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down