-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
pyright cannot infer nested generic classes with default values properly.
Code or Screenshots
from typing import Any, Generic
from collections.abc import Sequence
from typing_extensions import TypeVar, Self, reveal_type
_OrderableT = TypeVar("_OrderableT", default=Any)
class Interval(Generic[_OrderableT]):
def __new__(cls, left: _OrderableT, right: _OrderableT) -> Self: ...
IntervalT = TypeVar("IntervalT", bound=Interval, default=Interval)
S2 = TypeVar("S2")
class IntervalIndex(Generic[S2]):
def __new__(cls, data: Sequence[IntervalT]) -> IntervalIndex[IntervalT]: ...
reveal_type(Interval(0, 1)) # type checkers all give Interval[int]
reveal_type(IntervalIndex([Interval(0, 1)])) # mypy gives IntervalIndex[Interval[int]], pyright gives IntervalIndex[Interval[Any]]VS Code extension or command-line
Command line, pyright==1.1.407
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working