-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Basically type[IFoo[T]] causes T to become Unknown, where IFoo[T] doesn't. The problem is I'm passing a type not an instance so any issubclass checks then are invalid.
from typing import Protocol
class IFoo[T](Protocol):
@classmethod
def my_method(cls, value: T) -> None: ...
class Foo[T](IFoo[T]):
@classmethod
def my_method(cls, value: T) -> None: ...
class TestInstance[T]:
def __init__(self, interface: IFoo[T]) -> None: ...
class TestClass[T]:
def __init__(self, interface: type[IFoo[T]]) -> None: ...
f0 = TestInstance(Foo)
f1 = TestClass(Foo) # Type of "f1" is "TestClass[Unknown]" (reportUnknownVariableType)To get the issubclass checks to work I then have to immediately cast to the correct type: interface = cast(type[IFoo[T]], interface).
Oddly when using @overload with multiple static interfaces type matches correctly. Just the type parameters aren't set correctly. Using IFoo rather than type[IFoo] causes wrong matches.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working