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
Feature or enhancement
typing has had
type.__orig_bases__andtype.__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_basesas something likeand
typing.get_orig_class(side note, it might be possible to fully type
get_orig_classittypes.GenericAliaswas generic over the__origin__and__args__i.e.Foo[int] == GenericAlias[Foo, int])Linked PRs