Skip to content

Commit

Permalink
feat: add strict_cast, add py.typed
Browse files Browse the repository at this point in the history
  • Loading branch information
minenwerfer committed Aug 27, 2023
1 parent 5c1aa1e commit d5c9e3b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ packages = [
]

package-dir = { '' = 'src' }

[tool.setuptools.package-data]
'normalize_json' = ['py.typed']
3 changes: 2 additions & 1 deletion src/micromodel/micromodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file added src/micromodel/py.typed
Empty file.

0 comments on commit d5c9e3b

Please sign in to comment.