Things to check first
Typeguard version
4.2.1
Python version
3.12.1
What happened?
Typeguard reports incompatibilities between a the values of a type variable and its type (I hope that makes sense). The value of type_argument is Class, which is a type derived from Base, so it should be compatible with type[Base].
How can we reproduce the bug?
bug.py
from typing import Protocol, runtime_checkable
from typeguard import typechecked
@runtime_checkable
class Base(Protocol):
number: int
class Class(Base):
number: int
@typechecked
def bug(type_argument: type[Base]) -> None:
print(type_argument)
# mypy and pyright say this is OK:
type_argument: type[Base] = Class
# typeguard says this is not ok:
bug(Class)
mypy bug.py
pyright bug.py
python bug.py
typeguard.TypeCheckError: argument "type_argument" (class __main__.Class) is not compatible with the Base protocol
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
Typeguard version
4.2.1
Python version
3.12.1
What happened?
Typeguard reports incompatibilities between a the values of a type variable and its type (I hope that makes sense). The value of
type_argumentisClass, which is a type derived fromBase, so it should be compatible withtype[Base].How can we reproduce the bug?
bug.py