| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…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: python#2054
| for non-required keys. For required keys, type checkers may return | ||
| either the declared type ``T`` or ``T | None``. |
There was a problem hiding this comment.
Why leave this as an option? If the key is required, then it must be present so .get() can't return None.
Sorry, something went wrong.
| possible value types in ``d`` combined with ``None``. | ||
| - If the string value of ``e`` cannot be determined statically, the | ||
| return type is the union of all possible value types in ``d`` | ||
| combined with ``None``. (This simplifies to ``object | None`` if |
There was a problem hiding this comment.
Which is just object.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #2054.
The spec's .get() exception bullet only specified the return type for the variable-key case ("cannot be determined statically"), leaving two cases undefined:
This PR expands the bullet to cover all three cases explicitly:
Conformance test changes
The test had movie.get("other") # E? — the # E? marker is a wildcard that treats errors as optional (neither requiring nor forbidding one). Now that the spec is explicit, this becomes a plain call with no error marker.
pycroscope is the only checker that currently flags movie.get("other") as an error; its TOML is updated to Partial/Fail. All other checker TOMLs are updated for the +2-line shift caused by replacing the "not clear" comments with spec-quoting comments.
Files changed
Test plan