python / python/typing_extensions

Multiple inheritance and ReadOnly issues?

Open
#308 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
583
Forks
146
Avg merge
10h 11m
Merged PRs (30d)
5

Description

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'}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied reproducer with typing-extensions 4.9.0-rc1 on Python 3.10.1 and compare each reported key set with the expected assertions. Trace the TypedDict multiple-inheritance handling for Required, NotRequired, and ReadOnly, then add regression coverage showing that all assertions pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.