-
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 does not infer the type variable with a default properly when it comes to a Protocol.
Code or Screenshots
ttest.py:
from typing import Any, Generic, Protocol
from typing_extensions import Self, reveal_type, TypeVar
T_co = TypeVar("T_co", covariant=True)
S1 = TypeVar("S1", default=Any)
class SupportRou(Protocol[T_co]):
def __rou__(self) -> T_co: ...
def rou(obj: SupportRou[T_co]) -> T_co:
return obj.__rou__()
class Series(Generic[S1]):
def __rou__(self) -> Self:
return self
reveal_type(rou(Series())) # pyright gives Series[Unknown], mypy gives Series[Any]
reveal_type(rou(Series[int]())) # pyright and mypy both give Series[int]VS Code extension or command-line
poetry run pyright ttest.pyI have pyright 1.1.407, python 3.10.11 or 3.14.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working