python-datamodel 0.10.14__tar.gz → 0.10.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/PKG-INFO +1 -1
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/__init__.py +2 -1
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/abstract.py +45 -14
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/converters.c +30330 -16083
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/converters.html +18332 -10023
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/converters.pyx +866 -175
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/fields.cpp +648 -568
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/fields.html +567 -555
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/fields.pyx +8 -0
- python_datamodel-0.10.14/datamodel/validation.cpp → python_datamodel-0.10.16/datamodel/validation.c +9801 -4782
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/validation.html +3647 -1826
- python_datamodel-0.10.16/datamodel/validation.pxd +4 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/validation.pyx +301 -27
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/version.py +1 -1
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/python_datamodel.egg-info/PKG-INFO +1 -1
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/python_datamodel.egg-info/SOURCES.txt +4 -1
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/setup.py +5 -6
- python_datamodel-0.10.16/tests/test_container.py +265 -0
- python_datamodel-0.10.16/tests/test_generic.py +333 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_qsdriver.py +1 -1
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_tuples.py +3 -3
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_unions.py +1 -1
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/CHANGELOG.md +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/CONTRIBUTING.md +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/LICENSE +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/MANIFEST.in +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/Makefile +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/README.md +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/SECURITY.md +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/adaptive/__init__.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/adaptive/models.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/aliases/__init__.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/base.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/exceptions.c +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/exceptions.html +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/exceptions.pxd +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/exceptions.pyx +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/functions.cpp +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/functions.html +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/functions.pxd +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/functions.pyx +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/jsonld/__init__.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/jsonld/models.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/libs/__init__.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/libs/mapping.c +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/libs/mapping.html +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/libs/mapping.pxd +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/libs/mapping.pyx +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/libs/mutables.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/models.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/parsers/__init__.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/parsers/encoders.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/parsers/json.cpp +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/parsers/json.html +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/parsers/json.pyx +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/profiler.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/py.typed +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/rs_core/Cargo.toml +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/rs_core/src/lib.rs +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/rs_parsers/Cargo.toml +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/rs_parsers/src/lib.rs +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/rs_validators/Cargo.toml +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/rs_validators/src/lib.rs +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/__init__.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/singleton.c +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/singleton.html +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/singleton.pxd +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/singleton.pyx +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/types.c +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/types.html +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/types.pxd +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/typedefs/types.pyx +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/types.c +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/types.html +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/datamodel/types.pyx +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/pyproject.toml +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/python_datamodel.egg-info/dependency_links.txt +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/python_datamodel.egg-info/not-zip-safe +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/python_datamodel.egg-info/requires.txt +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/python_datamodel.egg-info/top_level.txt +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/setup.cfg +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/__init__.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_aliases.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_classdict.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_converter.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_dashboards.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_data.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_descriptors.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_dict.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_field.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_inherit.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_json.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_method.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_model.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_notify.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_primitives.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_qsmodel.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_qsobject.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_ticket.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_tickets.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_type_user.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_types.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_valid_callables.py +0 -0
- {python_datamodel-0.10.14 → python_datamodel-0.10.16}/tests/test_validations.py +0 -0
|
@@ -6,8 +6,9 @@ DataModel is a reimplementation of dataclasses with true inheritance and composi
|
|
|
6
6
|
from datamodel.fields import Field, Column, fields
|
|
7
7
|
from .models import Model
|
|
8
8
|
from .base import BaseModel
|
|
9
|
+
from .exceptions import ValidationError
|
|
9
10
|
from .version import (
|
|
10
11
|
__title__, __description__, __version__, __author__, __author_email__
|
|
11
12
|
)
|
|
12
13
|
|
|
13
|
-
__all__ = ('fields', 'Field', 'Column', 'Model', 'BaseModel', )
|
|
14
|
+
__all__ = ('fields', 'Field', 'Column', 'Model', 'BaseModel', 'ValidationError', )
|
|
@@ -264,12 +264,14 @@ class ModelMeta(type):
|
|
|
264
264
|
_type_category = 'primitive'
|
|
265
265
|
elif origin == type:
|
|
266
266
|
_type_category = 'type'
|
|
267
|
+
elif _type is set or _type is frozenset:
|
|
268
|
+
_type_category = 'set'
|
|
267
269
|
elif _is_dc:
|
|
268
270
|
_type_category = 'dataclass'
|
|
269
271
|
elif _is_typing or _is_alias: # noqa
|
|
270
272
|
if df.origin is not None and (df.origin is list and df.args):
|
|
271
273
|
df._inner_targs = df.args
|
|
272
|
-
df._inner_type = args[0]
|
|
274
|
+
df._inner_type = args[0] if args else Any
|
|
273
275
|
df._inner_origin = get_origin(df._inner_type)
|
|
274
276
|
df._typing_args = get_args(df._inner_type)
|
|
275
277
|
df._inner_is_dc = is_dataclass(df._inner_type)
|
|
@@ -277,16 +279,56 @@ class ModelMeta(type):
|
|
|
277
279
|
df._encoder_fn = encoders[df._inner_type]
|
|
278
280
|
except (TypeError, KeyError):
|
|
279
281
|
df._encoder_fn = None
|
|
282
|
+
# Handle list type
|
|
280
283
|
if origin is list:
|
|
281
284
|
df._inner_targs = df.args
|
|
282
|
-
df._inner_type = args[0]
|
|
285
|
+
df._inner_type = args[0] if args else Any
|
|
283
286
|
try:
|
|
284
287
|
df._encoder_fn = encoders[df._inner_type]
|
|
285
288
|
except (TypeError, KeyError):
|
|
286
289
|
df._encoder_fn = None
|
|
290
|
+
# Handle set type
|
|
291
|
+
elif origin is set:
|
|
292
|
+
df._inner_targs = df.args
|
|
293
|
+
df._inner_type = args[0] if args else Any
|
|
294
|
+
try:
|
|
295
|
+
df._encoder_fn = encoders[df._inner_type]
|
|
296
|
+
except (TypeError, KeyError):
|
|
297
|
+
df._encoder_fn = None
|
|
298
|
+
# Handle tuple type
|
|
299
|
+
elif origin is tuple:
|
|
300
|
+
df._inner_targs = df.args
|
|
301
|
+
# For tuple, use first arg if no Ellipsis, otherwise use it for all elements
|
|
302
|
+
has_ellipsis = len(args) == 2 and args[1] is Ellipsis
|
|
303
|
+
df._inner_type = args[0] if has_ellipsis or args else Any
|
|
304
|
+
try:
|
|
305
|
+
df._encoder_fn = encoders[df._inner_type]
|
|
306
|
+
except (TypeError, KeyError):
|
|
307
|
+
df._encoder_fn = None
|
|
308
|
+
# Handle dict type
|
|
309
|
+
elif origin is dict:
|
|
310
|
+
df._inner_targs = df.args
|
|
311
|
+
df._key_type = args[0] if len(args) > 0 else Any
|
|
312
|
+
df._value_type = args[1] if len(args) > 1 else Any
|
|
313
|
+
df._inner_origin = get_origin(df._value_type)
|
|
314
|
+
df._typing_args = get_args(df._value_type)
|
|
315
|
+
try:
|
|
316
|
+
df._key_encoder_fn = encoders[df._key_type]
|
|
317
|
+
except (TypeError, KeyError):
|
|
318
|
+
df._key_encoder_fn = None
|
|
319
|
+
try:
|
|
320
|
+
df._value_encoder_fn = encoders[df._value_type]
|
|
321
|
+
except (TypeError, KeyError):
|
|
322
|
+
df._value_encoder_fn = None
|
|
323
|
+
# Handle Union type
|
|
287
324
|
elif origin is Union:
|
|
288
325
|
df._inner_targs = df.args
|
|
289
|
-
|
|
326
|
+
try:
|
|
327
|
+
df._inner_type = args[0]
|
|
328
|
+
except IndexError as exc:
|
|
329
|
+
raise IndexError(
|
|
330
|
+
f"Union type {field} must have at least one type."
|
|
331
|
+
) from exc
|
|
290
332
|
df._inner_is_dc = is_dataclass(df._inner_type)
|
|
291
333
|
df._inner_priv = is_primitive(df._inner_type)
|
|
292
334
|
df._inner_origin = get_origin(df._inner_type)
|
|
@@ -294,8 +336,6 @@ class ModelMeta(type):
|
|
|
294
336
|
_type_category = 'typing'
|
|
295
337
|
elif isclass(_type):
|
|
296
338
|
_type_category = 'class'
|
|
297
|
-
# elif _is_alias:
|
|
298
|
-
# _type_category = 'typing'
|
|
299
339
|
else:
|
|
300
340
|
# TODO: making parser for complex types
|
|
301
341
|
_type_category = 'complex'
|
|
@@ -360,15 +400,6 @@ class ModelMeta(type):
|
|
|
360
400
|
_typing_args.update(new_typing_args)
|
|
361
401
|
aliases.update(new_aliases)
|
|
362
402
|
primary_keys.extend(nw_primary_keys)
|
|
363
|
-
|
|
364
|
-
# Store computed results in cache
|
|
365
|
-
# cls._base_class_cache[base_key] = {
|
|
366
|
-
# 'cols': cols.copy(),
|
|
367
|
-
# 'types': _types.copy(),
|
|
368
|
-
# '_typing_args': _typing_args.copy(),
|
|
369
|
-
# 'aliases': aliases.copy(),
|
|
370
|
-
# 'primary_keys': primary_keys.copy(),
|
|
371
|
-
# }
|
|
372
403
|
cache_entry = {
|
|
373
404
|
'cols': cols.copy(),
|
|
374
405
|
'types': _types.copy(),
|