Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix changelog entry for PEP 705 change #334

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- Add support for PEP 742, adding `typing_extensions.TypeIs`. Patch
by Jelle Zijlstra.
- Drop runtime error when a mutable `TypedDict` key overrides a read-only
- Drop runtime error when a read-only `TypedDict` item overrides a mutable
one. Type checkers should still flag this as an error. Patch by Jelle
Zijlstra.
- Speedup `issubclass()` checks against simple runtime-checkable protocols by
Expand Down
6 changes: 6 additions & 0 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4147,9 +4147,15 @@ def test_make_mutable_key_readonly(self):
class Base(TypedDict):
a: int

self.assertEqual(Base.__readonly_keys__, frozenset())
self.assertEqual(Base.__mutable_keys__, frozenset({'a'}))

class Child(Base):
a: ReadOnly[int] # type checker error, but allowed at runtime

self.assertEqual(Child.__readonly_keys__, frozenset({'a'}))
self.assertEqual(Child.__mutable_keys__, frozenset())

def test_can_make_readonly_key_mutable(self):
class Base(TypedDict):
a: ReadOnly[int]
Expand Down
1 change: 1 addition & 0 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ def __new__(cls, name, bases, ns, *, total=True):
else:
optional_keys.add(annotation_key)
if ReadOnly in qualifiers:
mutable_keys.discard(annotation_key)
readonly_keys.add(annotation_key)
else:
mutable_keys.add(annotation_key)
Expand Down
Loading