hashberg-io / typing-validation

A simple library for runtime type-checking.
https://typing-validation.readthedocs.io/
MIT License
7 stars 4 forks source link

Generic argument of `type` not considered by `validate`. #17

Closed sg495 closed 8 months ago

sg495 commented 8 months ago

Some validation against type is supported:

>>> from typing_validation import validate, can_validate
>>> class MyClass: pass
...
>>> can_validate(type[MyClass])
The following type can be validated against:
type[
    MyClass,
]
>>> validate(MyClass, type[MyClass])
True
>>> validate(10, Type[MyClass])
TypeError: Runtime validation error raised by validate(val, t), details below.
For type <class 'type'>, invalid value: 10

Unfortunately, the generic argument to type is not taken into consideration:

>>> validate(int, type[MyClass])
True