PEP484 allows TypeVar to be used anywhere, not necessarily in Generic classes, see this section.
However as of today the following fails:
from enforce import runtime_validation
from typing import TypeVar, Type
T = TypeVar('T', bound=int)
@runtime_validation
class Foo:
def foo(self, arg: Type[T]) -> T:
return arg()
With error:
(...)
File "C:\Miniconda3\envs\baseenv\lib\site-packages\enforce\enforcers.py", line 206, in generate_new_enforcer
raise TypeError('User defined generic does not accept provided constraints')
TypeError: User defined generic does not accept provided constraints
PEP484 allows
TypeVarto be used anywhere, not necessarily in Generic classes, see this section.However as of today the following fails:
With error: