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
$ mypy /tmp/test.py /tmp/test.py:13: error: Argument 2 to "replace" of "Foo" has incompatible type "**dict[str, object]"; expected "str" [arg-type]/tmp/test.py:13: error: Argument 2 to "replace" of "Foo" has incompatible type "**dict[str, object]"; expected "int" [arg-type]
$ mypy --versionmypy 1.5.1 (compiled: yes)
Apparently Mypy is trying to match each dict element type to class attributes (which is good), but not considering the fact that the 2nd parameter of replace() is a var-keyword therefore **dict is perfectly fine.
mypy infers {'bar': 'xyz', 'zee': 9} as dict[str, object], pyright infers as dict[str, Unknown], the latter is somewhat akin to Any. For example, this will be a false positive on pyright:
Bug Report
Calling
dataclasses.replace()
using a dict for dynamic arguments issues arg-type warnings.To Reproduce
Program output:
Expected Behavior
No warnings from mypy.
Actual Behavior
Apparently Mypy is trying to match each dict element type to class attributes (which is good), but not considering the fact that the 2nd parameter of
replace()
is a var-keyword therefore**dict
is perfectly fine.Your Environment
The text was updated successfully, but these errors were encountered: