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
The type of baz is dict[str, dict[int, str]], which isn't compatible with the declared type of the bar parameter in foo, so pylance is telling you about this type violation.
For more details about type declarations and generic types, refer to this documentation.
This gets a bit deep into type theory, but here are the details. The generic type dict accepts two type parameters, and both of them are "invariant", which means that the types must match exactly. That means dict[str, Any] is not type compatible with dict[str | int, Any] or vice versa.
@erictraut Thanks for your reply! What should I do if the "foo" function is provided by the "fastapi" package (router response argument). Explicitly specify type the "baz" variable like this?
Hey! I've encountered a very annoying bug that keeps bothering me. Please help how to fix this?
Environment data
Code Snippet
Repro Steps
Expected behavior
everything fine
Actual behavior
The text was updated successfully, but these errors were encountered: