Skip to content

Inferred type for type.__subclasses__() could be more specific #2236

Closed
@evelynchase

Description

@evelynchase

Example:

from typing import Sequence, List, Type

class A(object):
  pass

class B(A):
  pass

class C(A):
  pass

subs_1 = A.__subclasses__() # type: Sequence[Type[A]]
subs_2 = [t for t in A.__subclasses__() if issubclass(t, A)] # type: List[Type[A]]

Expected behavior

The inferred types for subs_1 and subs_2 are as annotated

Actual behavior

The inferred type is List[type] for both subs_1 and subs_2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions