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

Multiple inheritance and ReadOnly issues? #308

Open
alicederyn opened this issue Nov 29, 2023 · 1 comment
Open

Multiple inheritance and ReadOnly issues? #308

alicederyn opened this issue Nov 29, 2023 · 1 comment

Comments

@alicederyn
Copy link
Contributor

alicederyn commented Nov 29, 2023

I believe the following should be a passing test suite for multiple inheritance and ReadOnly:

from typing_extensions import TypedDict, Required, NotRequired, ReadOnly

class A(TypedDict):
  k: ReadOnly[Required[int]]
  
class B(TypedDict):
  k: ReadOnly[NotRequired[int]]

class C(A, B): pass

assert C.__required_keys__ == {'k'}
assert C.__optional_keys__ == set()

class D(B, A): pass 

assert D.__required_keys__ == {'k'}
assert D.__optional_keys__ == set()

class E(TypedDict):
  k: Required[int]
  
class F(A, E): pass

assert F.__readonly_keys__ == set()
assert F.__mutable_keys__ == {'k'}

class G(E, A): pass

assert G.__readonly_keys__ == set()
assert G.__mutable_keys__ == {'k'}

Unfortunately, with typing-extensions 4.9.0-rc1 in Python 3.10.1, every one of these properties is {'k'}

@JelleZijlstra
Copy link
Member

I'm going to punt on fixing this until after 4.9.0 since it feels fairly obscure.

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

No branches or pull requests

2 participants