Discrepancy between spec and tests on indexing TypedDicts with unknown literal keys
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
- 領域
- documentation, testing
研究方向
將引用的規範要求與 conformance/tests/typeddicts_operations.py 進行比較,然後查看連結的討論和相關 PR,以了解型別檢查器行為的差異。確定應修改一致性測試還是規範;完成的標準是消除歧義,並使規範與測試保持一致。
由索引模型根據 Issue 內容生成。
描述
Splitting issue from PR https://github.com/python/typing/pull/1978
Spec says that indexing with unknown literal keys should be reported as an error:
The use of a key that is not known to exist should be reported as an error, even if this wouldn’t necessarily generate a runtime type error. These are often mistakes, and these may insert values with an invalid type if structural assignability hides the types of certain items. For example, d[‘x’] = 1 should generate a type check error if ‘x’ is not a valid key for d (which is assumed to be a TypedDict type).
But it's not reflected in conformance tests (https://github.com/python/typing/blob/2d88da2a407b556f5b52b4c6ad1bd659873bb9ac/conformance/tests/typeddicts_operations.py) and there's a bit of discrepancy between type checkers how they handle some cases (most of them reject all cases that may cause runtime error / allow cases that do not cause runtime error ).
Would be great if we can either adapt conformance tests to the spec or amend the spec to remove the ambiguity.
Related discussion - https://discuss.python.org/t/typeddict-operations-with-unknown-literal-keys/89653 (also has information on state of this issue in different type checkers).
- 主要語言
- Python
- 星號
- 1.8k
- 分支
- 302
- 平均合併
- 4 小時 16 分鐘
- 30 天內合併 PR
- 7
環境準備
我們還沒有檢查這個專案的環境設定檔。先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/typing 的其他 Issue
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 72/100
python/typing#2356 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
topic: typing spec
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
topic: documentation
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
topic: documentation
難度 2/5 1-3 小時 新手友好度 65/100
python/typing#2150 · 2 則留言 · 2 個 reaction ·
維護者通常 1 天內回覆
-
topic: conformance tests topic: typing spec
難度 3/5 1-2 天 新手友好度 72/100
維護者通常 1 天內回覆
相似的 Issue
-
ACK_WAITING HELP_WANTED UPDATE_CS
難度 2/5 1-3 小時 新手友好度 78/100
OWASP/CheatSheetSeries#2458 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 90/100
BasedHardware/omi#19711 ·
維護者通常 1 天內回覆
-
Qwen3_5MoeModel no longer returns router_logits, breaking aux loss with output_router_logits=True未關閉
難度 2/5 1-3 小時 新手友好度 78/100
huggingface/transformers#49172 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
vllm-project/vllm-metal#885 ·
維護者通常 1 天內回覆