Skip to content

Check the underlying type of read-only TypedDict extra items - #596

Open
agammann wants to merge 1 commit into
agronholm:masterfrom
agammann:fix-readonly-extra-items
Open

agammann wants to merge 1 commit into
agronholm:masterfrom
agammann:fix-readonly-extra-items

Conversation

@agammann

Copy link
Copy Markdown

TypedDict(extra_items=ReadOnly[int]) currently accepts extra values of any type because the ReadOnly wrapper is passed directly to the internal checker. Named fields already unwrap this qualifier, but extra fields do not.

Unwrap ReadOnly before checking extra values. Add a regression that accepts an integer and rejects a string, including the extra key in the error path.

Validation on Python 3.12: the regression fails before the fix. The full suite passes afterward (536 passed, 9 skipped, 9 expected failures), and Ruff 0.15.20 lint/format checks pass for the changed files. Mypy reports an existing missing typeshed.stdlib.types import in _decorators.py; the same error was confirmed in a clean worktree at the original commit.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.859% (+0.006%) from 94.853% — agammann:fix-readonly-extra-items into agronholm:master

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants