Skip to content

Supporting TypeVar's in type validation #154

Open
@ZeroIntensity

Description

@ZeroIntensity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    c apiThis has to do with the C API (_view)complexThis should only be looked at by someone who knows what they're doingimprovementImprovement to an existing feature

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions