Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
typing has had type.__orig_bases__ and type.__orig_class__ for quite some time now, there is no stable API to access these attributes.
Pitch
I would like to propose adding typing.get_orig_bases as something like
@overloaddefget_orig_bases(cls: type[object]) ->tuple[type[Any], ...] |None: ... @overloaddefget_orig_bases(cls: Any) ->None: ... defget_orig_bases(cls: Any) ->tuple[type[Any], ...] |None: returngetattr(cls, "__orig_bases__", None)and typing.get_orig_class
@overloaddefget_orig_class(cls: type[object]) ->GenericAlias|None: ... @overloaddefget_orig_class(cls: Any) ->None: ... defget_orig_class(cls: Any) ->GenericAlias|None: returngetattr(cls, "__orig_class__", None)(side note, it might be possible to fully type get_orig_class it types.GenericAlias was generic over the __origin__ and __args__ i.e. Foo[int] == GenericAlias[Foo, int])
Linked PRs
Fidget-Spinner, hmc-cs-mdrissi and vbrozik
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-featureA feature request or enhancementA feature request or enhancement