Skip to content

typing: Inheritance with NotRequired or Required in parent fields is not tested  #101562

Closed
@Eclips4

Description

@Eclips4

Such case Lib/test/test_typing.py doesn't cover.

from typing import TypedDict, Required, NotRequired, get_type_hints

class Parent(TypedDict, total=False):
    field: Required[str]

class Child(Parent):
    another_field: NotRequired[str]
    
 assert Child.__required_keys__ == frozenset({"field": str})
 assert Child.__optional_keys__ == frozenset({"another_field": str})

I think, we should test it.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions