From d5c9e3b4144654805422724539f175272befae4c Mon Sep 17 00:00:00 2001 From: ringeringeraja Date: Sun, 27 Aug 2023 02:19:07 -0300 Subject: [PATCH] feat: add strict_cast, add py.typed --- pyproject.toml | 3 +++ src/micromodel/micromodel.py | 3 ++- src/micromodel/py.typed | 0 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/micromodel/py.typed diff --git a/pyproject.toml b/pyproject.toml index 5b45bf5..ea74eff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,3 +22,6 @@ packages = [ ] package-dir = { '' = 'src' } + +[tool.setuptools.package-data] +'normalize_json' = ['py.typed'] diff --git a/src/micromodel/micromodel.py b/src/micromodel/micromodel.py index 821efd6..9fef17f 100644 --- a/src/micromodel/micromodel.py +++ b/src/micromodel/micromodel.py @@ -21,7 +21,8 @@ def __init__(self, model_type: typing.Callable[[typing.Any], T], ct: dict[str, t if coll: self.coll = coll - def cast(self, target: T | dict[str, typing.Any]): return typing.cast(T, target) + def cast(self, target: T | typing.Any): return typing.cast(T, target) + def strict_cast(self, target: T): return target def validate(self, target: T, options: ValidationOptions = {}): return validate(self.model_type, typing.cast(typing.Any, target), options, self.ct) def find(self, *args: typing.Any, **kwargs: typing.Any): diff --git a/src/micromodel/py.typed b/src/micromodel/py.typed new file mode 100644 index 0000000..e69de29