view.py
view.py copied to clipboard
Supporting TypeVar's in type validation
Improvement Description
Along with #153, View does not support TypeVar being used in the type validation API. This isn't nearly as important as Literal, but should still be implemented.
Improvement Request Example API
from view import compile_type
from typing import TypeVar, Generic
from dataclasses import dataclass
T = TypeVar("T")
@dataclass
class Thing(Generic[T]):
hello: T
world: T
tp = compile_type(Thing)
tp.cast('{"hello": "world", "world": "hello"}') # creates Thing instance
tp.is_compatible('{"hello": "world", "world": 1}') # T is not the same across the object, returns False
Anything else?
No response