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
Incompatible override with **kwargs TypedDict and Any #13491
This is not a bug. This actually violates Liskov. The suppertype can accept arbitrary keywords, while subtype only some.
Doesn't that depend on the definition of completeness? I.e. the TypedDict defines the keyword arguments which must be present, but just technically you can still pass any other arguments to it, as well. The code wouldn't break.
I also checked pyright, which does not emit an error, at the moment.
If you really want to express "I don't care about arguments", use *args: Any, **kwargs: Any. Mypy special-cases this as "whatever works".
Adding *args isn't an option in this case, unfortunately.
Activity
ilevkivskyi commentedon Aug 23, 2022
This is not a bug. This actually violates Liskov. The suppertype can accept arbitrary keywords, while subtype only some.
If you really want to express "I don't care about arguments", use
*args: Any, **kwargs: Any. Mypy special-cases this as "whatever works".cdce8p commentedon Aug 23, 2022
Doesn't that depend on the definition of completeness? I.e. the TypedDict defines the keyword arguments which
mustbe present, but just technically you can still pass any other arguments to it, as well. The code wouldn't break.I also checked pyright, which does not emit an error, at the moment.
Adding
*argsisn't an option in this case, unfortunately.ilevkivskyi commentedon Aug 23, 2022
Allowing arbitrary keywords will significantly reduce safety. Imagine:
Well, use pyright then.