Skip to content

Support type inference for __orig_bases__ as defined in PEP 560 #3442

Closed
@huntzhan

Description

@huntzhan

Is your feature request related to a problem? Please describe.
A clear and concise description of the problem.

__orig_bases__ is defined in PEP 560. Currently pyright does not infer the type of cls.__orig_bases__. For example,

from typing import Generic, TypeVar

T = TypeVar('T')


class Base(Generic[T]):
    pass


class Derived(Base[int]):
    pass


Derived.__orig_bases__

Hovering on the Derived.__orig_bases__ shows:

image

And the value of Derived.__orig_bases__ is (__main__.Base[int],)

image

Describe the solution you'd like
A clear and concise description of what you want to happen.

This feature is helpful for writing type reflection code. Would be great if inferring the type of cls.__orig_bases__ is supported.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions