Skip to content

Instantly share code, notes, and snippets.

View cwells's full-sized avatar

Cliff Wells cwells

  • Portland, Oregon USA
  • 00:40 (UTC -07:00)
View GitHub Profile
from typing import Any, TypedDict, Union
from typeguard import CollectionCheckStrategy, check_type
class TypedObject:
def __init__(self, object_type: Any) -> None:
self.object_type = object_type
def validate(self, value: Any) -> Any:
check_type(
import json
from typing import Any, TypedDict, Union, Callable, Optional
from typeguard import CollectionCheckStrategy, check_type
Serializer = Optional[Callable]
def typed_object_factory(object_type: Any, serializer: Serializer=None):
class TypedObject: