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
typeddict: clarify that .get() with an unknown literal key is not an error
The spec's `.get()` bullet only specified the return type for the
variable-key case ("cannot be determined statically"), leaving the
literal-key cases undefined. Expand the bullet to cover all three
cases:
1. Known literal key — return type is ``T | None`` for non-required
keys; type checkers may return ``T`` or ``T | None`` for required.
2. Unknown literal key — NOT an error; return type is the union of
all value types combined with ``None``.
3. Non-literal key — unchanged: union of all value types | ``None``.
The conformance test had ``movie.get("other") # E?``, which the runner
treats as "optional" (neither requiring nor forbidding an error). Now
that the spec is explicit, change it to a plain call with no error
marker, and update the surrounding comments to quote the spec.
pycroscope is the only checker that flags ``movie.get("other")`` as an
error; its TOML now shows Partial/Fail reflecting this non-conformance.
All other checker TOMLs updated for the +2-line shift.
Fixes: #2054
Copy file name to clipboardExpand all lines: conformance/results/ty/typeddicts_operations.toml
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ typeddicts_operations.py:28:9: error[missing-typed-dict-key] Missing required ke
10
10
typeddicts_operations.py:29:42: error[invalid-argument-type] Invalid argument to key "year" with declared type `int` on TypedDict `Movie`: value of type `float`
11
11
typeddicts_operations.py:32:36: error[invalid-key] Unknown key "other" for TypedDict `Movie`
12
12
typeddicts_operations.py:37:20: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
13
-
typeddicts_operations.py:47:1: error[unresolved-attribute] Object of type `Movie` has no attribute `clear`
14
-
typeddicts_operations.py:49:11: error[invalid-argument-type] Cannot delete required key "name" from TypedDict `Movie`
15
-
typeddicts_operations.py:62:1: error[unresolved-attribute] Object of type `MovieOptional` has no attribute `clear`
13
+
typeddicts_operations.py:49:1: error[unresolved-attribute] Object of type `Movie` has no attribute `clear`
14
+
typeddicts_operations.py:51:11: error[invalid-argument-type] Cannot delete required key "name" from TypedDict `Movie`
15
+
typeddicts_operations.py:64:1: error[unresolved-attribute] Object of type `MovieOptional` has no attribute `clear`
0 commit comments