-
Notifications
You must be signed in to change notification settings - Fork 263
Open
Labels
topic: typing specFor improving the typing specFor improving the typing spec
Description
Splitting issue from PR #1978
Spec says that it should be generally rejected (ref)
A key that is not a literal should generally be rejected, since its value is unknown during type checking, and thus can cause some of the above violations.
But currently conformance tests do not reflect it.
typing/conformance/tests/typeddicts_operations.py
Lines 34 to 38 in 2d88da2
def func1(variable_key: str): | |
# > A key that is not a literal should generally be rejected. | |
movie: Movie = {variable_key: "", "year": 1900} # E: variable key | |
So in theory to resolve this, either strictness should be reflected in conformance tests or spec should be amended allowing optional enforcement.
Related discussion - https://discuss.python.org/t/indexing-typeddict-with-a-non-literal-variable/88929
Metadata
Metadata
Assignees
Labels
topic: typing specFor improving the typing specFor improving the typing spec