You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dict unpacking type checks don't consider **kwargs #17642
In the below example (playground gist), mypy behaves differently with respect to **kwargs:
deffunc(x: bool=False, **kwargs):
print(x, kwargs)
# This is accepted by mypy.func(y="y")
# This is flagged by mypy.data= {"y": "y"}
func(**data)
The error is Argument 1 to "func" has incompatible type "**dict[str, str]"; expected "bool" [arg-type]. This is incorrect because the function has **kwargs, so the dict / function call should be considered type correct.
Your Environment:
Mypy version used: latest (1.11.1)
Mypy command-line flags: -
Mypy configuration options from mypy.ini (and other config files): -
Activity
153957 commentedon Oct 15, 2024
Some related issues:
dinatamas commentedon Dec 1, 2024
I have overlooked that
datamay specifyx.Since mypy has no way to know the content of the dictionary (unless it's a TypedDict or frozendict), it is correct to flag this function call.
If
funconly expects strings, mypy accepts this.It also accepts this if
xis explicitly provided.dinatamas commentedon Dec 1, 2024
Hence mypy's behavior is correct and I'm closing this ticket.
ruff and mypy. mypy sucks. python/mypy#17642
[llm unify 7/n] Summarize (#1192)
STY: Ignore type checking error when passing keyword arguments
STY: Ignore type checking error when passing keyword arguments