Replies: 2 comments 1 reply
-
|
I'd have to investigate in more detail to confirm, but I suspect the problem is because your definition of When you explicitly implement |
Beta Was this translation helpful? Give feedback.
-
|
Oh, I forgot one more strange behavior I found: If I make a from __future__ import annotations
from typing import Any, Generic, Protocol, Self, TypeAlias, TypeVar
class P(Protocol):
def f(self, a_num: int, arg: C1[Self]) -> Any: ...
T = TypeVar("T", bound=P)
class C1(Generic[T]):
def __init__(self, t: T):
self.t = t
_: TypeAlias = "C1[ConcreteP]"
class ConcreteP:
def f(self, a_num: int, arg: C1[ConcreteP]) -> Any:
return a_num, arg(I had to change |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Minimal-ish example that demonstrates behavior I can't explain:
I'm just... sorry, this code is a mess, but it's the result of me trying to narrow down my actual code to reproduce the problem. Basically C1 and C2 want to work together to do things with an object that satisfies protocol P.
When I run Pyright 1.1.407 on this file (Python 3.13.11) I get this error:
Note that Mypy (1.19.0) does not give me any errors on this code.
If I make
ConcretePexplicitly implement P (class ConcreteP(P)), the error goes away.My questions are:
"(a_num: int) -> Unknown"? Is this something like the Pyright recursing too deep and halting while trying to process this type?Thanks for any help! This is stumping me.
Beta Was this translation helpful? Give feedback.
All reactions