Discrepancy between spec and tests on indexing TypedDicts with non-literal variables
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
Splitting issue from PR https://github.com/python/typing/pull/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.
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypedDict operations spec section and conformance/tests/typeddicts_operations.py around lines 34-38, then read PR 1978 and the linked discussion. Determine whether the conformance tests should reject non-literal indexing or the specification should allow optional enforcement. Done means the spec and conformance tests consistently describe the agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation, testing
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100