dict type hints should only take 1 or 2 inputs #1247
randolf-scholz
started this conversation in
General
Replies: 1 comment
-
Type checkers like mypy or pyright will generate an error if you supply too many type arguments. The Python runtime doesn't enforce this because generic types are erased at runtime. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It is weird that it is allowed to write something like
dict[str, int, float]
without raising an error.A suggestion:
dict
⇝dict[Any, Any]
dict[key_type]
⇝dict[key_type, Any]
dict[key_type, value_type]
dict[...]
with ≥3 arguments raises Error.Beta Was this translation helpful? Give feedback.
All reactions