datamodel-code-generator 0.25.2__py3-none-any.whl → 0.25.4__py3-none-any.whl
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.
Potentially problematic release.
This version of datamodel-code-generator might be problematic. Click here for more details.
- datamodel_code_generator/__init__.py +1 -1
- datamodel_code_generator/format.py +21 -4
- datamodel_code_generator/model/base.py +1 -1
- datamodel_code_generator/model/pydantic/base_model.py +5 -3
- datamodel_code_generator/parser/jsonschema.py +11 -6
- datamodel_code_generator/util.py +8 -3
- datamodel_code_generator/version.py +1 -1
- {datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/METADATA +3 -3
- {datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/RECORD +12 -12
- {datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/LICENSE +0 -0
- {datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/WHEEL +0 -0
- {datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/entry_points.txt +0 -0
|
@@ -525,7 +525,7 @@ def infer_input_type(text: str) -> InputFileType:
|
|
|
525
525
|
|
|
526
526
|
|
|
527
527
|
inferred_message = (
|
|
528
|
-
'The input file type was determined to be: {}\nThis can be
|
|
528
|
+
'The input file type was determined to be: {}\nThis can be specified explicitly with the '
|
|
529
529
|
'`--input-file-type` option.'
|
|
530
530
|
)
|
|
531
531
|
|
|
@@ -11,6 +11,11 @@ import isort
|
|
|
11
11
|
|
|
12
12
|
from datamodel_code_generator.util import cached_property, load_toml
|
|
13
13
|
|
|
14
|
+
try:
|
|
15
|
+
import black.mode
|
|
16
|
+
except ImportError: # pragma: no cover
|
|
17
|
+
black.mode = None
|
|
18
|
+
|
|
14
19
|
|
|
15
20
|
class PythonVersion(Enum):
|
|
16
21
|
PY_36 = '3.6'
|
|
@@ -131,9 +136,15 @@ class CodeFormatter:
|
|
|
131
136
|
if wrap_string_literal is not None:
|
|
132
137
|
experimental_string_processing = wrap_string_literal
|
|
133
138
|
else:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
if black.__version__ < '24.1.0': # type: ignore
|
|
140
|
+
experimental_string_processing = config.get(
|
|
141
|
+
'experimental-string-processing'
|
|
142
|
+
)
|
|
143
|
+
else:
|
|
144
|
+
experimental_string_processing = config.get('preview', False) and (
|
|
145
|
+
config.get('unstable', False)
|
|
146
|
+
or 'string_processing' in config.get('enable-unstable-feature', [])
|
|
147
|
+
)
|
|
137
148
|
|
|
138
149
|
if experimental_string_processing is not None: # pragma: no cover
|
|
139
150
|
if black.__version__.startswith('19.'): # type: ignore
|
|
@@ -141,10 +152,16 @@ class CodeFormatter:
|
|
|
141
152
|
f"black doesn't support `experimental-string-processing` option" # type: ignore
|
|
142
153
|
f' for wrapping string literal in {black.__version__}'
|
|
143
154
|
)
|
|
144
|
-
|
|
155
|
+
elif black.__version__ < '24.1.0': # type: ignore
|
|
145
156
|
black_kwargs[
|
|
146
157
|
'experimental_string_processing'
|
|
147
158
|
] = experimental_string_processing
|
|
159
|
+
elif experimental_string_processing:
|
|
160
|
+
black_kwargs['preview'] = True
|
|
161
|
+
black_kwargs['unstable'] = config.get('unstable', False)
|
|
162
|
+
black_kwargs['enabled_features'] = {
|
|
163
|
+
black.mode.Preview.string_processing
|
|
164
|
+
}
|
|
148
165
|
|
|
149
166
|
if TYPE_CHECKING:
|
|
150
167
|
self.black_mode: black.FileMode
|
|
@@ -63,7 +63,7 @@ class ConstraintsBase(_BaseModel):
|
|
|
63
63
|
|
|
64
64
|
@cached_property
|
|
65
65
|
def has_constraints(self) -> bool:
|
|
66
|
-
return any(v for v in self.dict().values()
|
|
66
|
+
return any(v is not None for v in self.dict().values())
|
|
67
67
|
|
|
68
68
|
@staticmethod
|
|
69
69
|
def merge_constraints(
|
|
@@ -87,7 +87,9 @@ class DataModelField(DataModelFieldBase):
|
|
|
87
87
|
return result
|
|
88
88
|
|
|
89
89
|
def self_reference(self) -> bool:
|
|
90
|
-
return isinstance(
|
|
90
|
+
return isinstance(
|
|
91
|
+
self.parent, BaseModelBase
|
|
92
|
+
) and self.parent.reference.path in {
|
|
91
93
|
d.reference.path for d in self.data_type.all_data_types if d.reference
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -111,12 +113,12 @@ class DataModelField(DataModelFieldBase):
|
|
|
111
113
|
data_type = data_type.data_types[0]
|
|
112
114
|
if (
|
|
113
115
|
data_type.reference
|
|
114
|
-
and isinstance(data_type.reference.source,
|
|
116
|
+
and isinstance(data_type.reference.source, BaseModelBase)
|
|
115
117
|
and isinstance(self.default, list)
|
|
116
118
|
): # pragma: no cover
|
|
117
119
|
return f'lambda :[{data_type.alias or data_type.reference.source.class_name}.{self._PARSE_METHOD}(v) for v in {repr(self.default)}]'
|
|
118
120
|
elif data_type.reference and isinstance(
|
|
119
|
-
data_type.reference.source,
|
|
121
|
+
data_type.reference.source, BaseModelBase
|
|
120
122
|
): # pragma: no cover
|
|
121
123
|
return f'lambda :{data_type.alias or data_type.reference.source.class_name}.{self._PARSE_METHOD}({repr(self.default)})'
|
|
122
124
|
return None
|
|
@@ -270,6 +270,8 @@ class JsonSchemaObject(BaseModel):
|
|
|
270
270
|
def __init__(self, **data: Any) -> None:
|
|
271
271
|
super().__init__(**data)
|
|
272
272
|
self.extras = {k: v for k, v in data.items() if k not in EXCLUDE_FIELD_KEYS}
|
|
273
|
+
if 'const' in data.get(self.__extra_key__, {}):
|
|
274
|
+
self.extras['const'] = data[self.__extra_key__]['const']
|
|
273
275
|
|
|
274
276
|
@cached_property
|
|
275
277
|
def is_object(self) -> bool:
|
|
@@ -367,6 +369,7 @@ EXCLUDE_FIELD_KEYS = (
|
|
|
367
369
|
@snooper_to_methods(max_variable_length=None)
|
|
368
370
|
class JsonSchemaParser(Parser):
|
|
369
371
|
SCHEMA_PATHS: ClassVar[List[str]] = ['#/definitions', '#/$defs']
|
|
372
|
+
SCHEMA_OBJECT_TYPE: ClassVar[Type[JsonSchemaObject]] = JsonSchemaObject
|
|
370
373
|
|
|
371
374
|
def __init__(
|
|
372
375
|
self,
|
|
@@ -686,7 +689,7 @@ class JsonSchemaParser(Parser):
|
|
|
686
689
|
# }
|
|
687
690
|
else:
|
|
688
691
|
combined_schemas.append(
|
|
689
|
-
|
|
692
|
+
self.SCHEMA_OBJECT_TYPE.parse_obj(
|
|
690
693
|
self._deep_merge(
|
|
691
694
|
base_object,
|
|
692
695
|
target_attribute.dict(exclude_unset=True, by_alias=True),
|
|
@@ -1632,7 +1635,7 @@ class JsonSchemaParser(Parser):
|
|
|
1632
1635
|
raw: Dict[str, Any],
|
|
1633
1636
|
path: List[str],
|
|
1634
1637
|
) -> None:
|
|
1635
|
-
self.parse_obj(name,
|
|
1638
|
+
self.parse_obj(name, self.SCHEMA_OBJECT_TYPE.parse_obj(raw), path)
|
|
1636
1639
|
|
|
1637
1640
|
def parse_obj(
|
|
1638
1641
|
self,
|
|
@@ -1759,7 +1762,7 @@ class JsonSchemaParser(Parser):
|
|
|
1759
1762
|
# Some jsonschema docs include attribute self to have include version details
|
|
1760
1763
|
raw.pop('self', None)
|
|
1761
1764
|
# parse $id before parsing $ref
|
|
1762
|
-
root_obj =
|
|
1765
|
+
root_obj = self.SCHEMA_OBJECT_TYPE.parse_obj(raw)
|
|
1763
1766
|
self.parse_id(root_obj, path_parts)
|
|
1764
1767
|
definitions: Optional[Dict[Any, Any]] = None
|
|
1765
1768
|
for schema_path, split_schema_path in self.schema_paths:
|
|
@@ -1773,13 +1776,15 @@ class JsonSchemaParser(Parser):
|
|
|
1773
1776
|
definitions = {}
|
|
1774
1777
|
|
|
1775
1778
|
for key, model in definitions.items():
|
|
1776
|
-
obj =
|
|
1779
|
+
obj = self.SCHEMA_OBJECT_TYPE.parse_obj(model)
|
|
1777
1780
|
self.parse_id(obj, [*path_parts, schema_path, key])
|
|
1778
1781
|
|
|
1779
1782
|
if object_paths:
|
|
1780
1783
|
models = get_model_by_path(raw, object_paths)
|
|
1781
1784
|
model_name = object_paths[-1]
|
|
1782
|
-
self.parse_obj(
|
|
1785
|
+
self.parse_obj(
|
|
1786
|
+
model_name, self.SCHEMA_OBJECT_TYPE.parse_obj(models), path
|
|
1787
|
+
)
|
|
1783
1788
|
else:
|
|
1784
1789
|
self.parse_obj(obj_name, root_obj, path_parts or ['#'])
|
|
1785
1790
|
for key, model in definitions.items():
|
|
@@ -1800,7 +1805,7 @@ class JsonSchemaParser(Parser):
|
|
|
1800
1805
|
models = get_model_by_path(raw, object_paths)
|
|
1801
1806
|
model_name = object_paths[-1]
|
|
1802
1807
|
self.parse_obj(
|
|
1803
|
-
model_name,
|
|
1808
|
+
model_name, self.SCHEMA_OBJECT_TYPE.parse_obj(models), path
|
|
1804
1809
|
)
|
|
1805
1810
|
previous_reserved_refs = reserved_refs
|
|
1806
1811
|
reserved_refs = set(self.reserved_refs.get(key) or [])
|
datamodel_code_generator/util.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import copy
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
from typing import TYPE_CHECKING, Any, Callable, Dict, TypeVar
|
|
5
6
|
|
|
@@ -69,9 +70,13 @@ else:
|
|
|
69
70
|
return toml.load(path)
|
|
70
71
|
|
|
71
72
|
|
|
72
|
-
SafeLoader
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
SafeLoaderTemp = copy.deepcopy(SafeLoader)
|
|
74
|
+
SafeLoaderTemp.yaml_constructors = copy.deepcopy(SafeLoader.yaml_constructors)
|
|
75
|
+
SafeLoaderTemp.add_constructor(
|
|
76
|
+
'tag:yaml.org,2002:timestamp',
|
|
77
|
+
SafeLoaderTemp.yaml_constructors['tag:yaml.org,2002:str'],
|
|
78
|
+
)
|
|
79
|
+
SafeLoader = SafeLoaderTemp
|
|
75
80
|
|
|
76
81
|
Model = TypeVar('Model', bound=_BaseModel)
|
|
77
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
version: str = '0.25.
|
|
1
|
+
version: str = '0.25.4'
|
{datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: datamodel-code-generator
|
|
3
|
-
Version: 0.25.
|
|
3
|
+
Version: 0.25.4
|
|
4
4
|
Summary: Datamodel Code Generator
|
|
5
5
|
Home-page: https://github.com/koxudaxi/datamodel-code-generator
|
|
6
6
|
License: MIT
|
|
@@ -377,7 +377,7 @@ Options:
|
|
|
377
377
|
--http-ignore-tls Disable verification of the remote host's TLS
|
|
378
378
|
certificate
|
|
379
379
|
--input INPUT Input file/directory (default: stdin)
|
|
380
|
-
--input-file-type {auto,openapi,jsonschema,json,yaml,dict,csv}
|
|
380
|
+
--input-file-type {auto,openapi,graphql,jsonschema,json,yaml,dict,csv}
|
|
381
381
|
Input file type (default: auto)
|
|
382
382
|
--output OUTPUT Output file (default: stdout)
|
|
383
383
|
--output-model-type {pydantic.BaseModel,pydantic_v2.BaseModel,dataclasses.dataclass,typing.TypedDict,msgspec.Struct}
|
|
@@ -467,7 +467,7 @@ Model customization:
|
|
|
467
467
|
--enable-version-header
|
|
468
468
|
Enable package version on file headers
|
|
469
469
|
--keep-model-order Keep generated models' order
|
|
470
|
-
--reuse-model
|
|
470
|
+
--reuse-model Reuse models on the field when a module has the model
|
|
471
471
|
with the same content
|
|
472
472
|
--target-python-version {3.6,3.7,3.8,3.9,3.10,3.11}
|
|
473
473
|
target python version (default: 3.7)
|
{datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/RECORD
RENAMED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
datamodel_code_generator/__init__.py,sha256=
|
|
1
|
+
datamodel_code_generator/__init__.py,sha256=cCmyB7qRG9GE6wNQmTcY7MC_rY43yryxyhxLlVav1EA,17715
|
|
2
2
|
datamodel_code_generator/__main__.py,sha256=7yvaMVa8KXwFUzBwiuKVzD-bs-tO66oGcIzWW3ZAOSI,18496
|
|
3
3
|
datamodel_code_generator/arguments.py,sha256=N5dOWb_cR5orktDK1FeGy7txVN566mxRlGkvyGeTVaY,14594
|
|
4
|
-
datamodel_code_generator/format.py,sha256=
|
|
4
|
+
datamodel_code_generator/format.py,sha256=eC_TTYICLDtM4Y_mbdT9PNjxzwuWSirwaOc5pyTt0to,8625
|
|
5
5
|
datamodel_code_generator/http.py,sha256=WYScR7rqz8GjgdVPPhFp4PJzgON5DPpO1vmHQLDxYxE,590
|
|
6
6
|
datamodel_code_generator/imports.py,sha256=SJmkUIxHPCH3rDLMdXsUcT5pPfT9rjc-nmREOLx4Kxw,5283
|
|
7
7
|
datamodel_code_generator/model/__init__.py,sha256=A0CqnL87-lY_Te-n-99ya5v7h6l4jE6hOPP_itvcWOc,3091
|
|
8
|
-
datamodel_code_generator/model/base.py,sha256=
|
|
8
|
+
datamodel_code_generator/model/base.py,sha256=WshtblvxQ9fiRE2G7bdFiDRu6aDGSPhcIiiGIIBp1hg,14023
|
|
9
9
|
datamodel_code_generator/model/dataclass.py,sha256=9meJNWb-XPYYO8kDMSLhSfO6fulGWV7r3_XIM5kA71M,3965
|
|
10
10
|
datamodel_code_generator/model/enum.py,sha256=Giehhtij2DZs2LssSJnG_CIIHsSA7Mkz471GU-Cb5kI,3338
|
|
11
11
|
datamodel_code_generator/model/imports.py,sha256=9-0bd-DvZRjZkWMsmw-gykL8fzTd6M-vQEqS7Rm_ty4,725
|
|
12
12
|
datamodel_code_generator/model/msgspec.py,sha256=_568E91e07NX-A1bOeITOqr3h1Cr9ykecoSYeIZ5PwI,8934
|
|
13
13
|
datamodel_code_generator/model/pydantic/__init__.py,sha256=AYMjDCtnV4vweYqe1asTRCYdOo8IGLBhd8pEdxyY8ok,1372
|
|
14
|
-
datamodel_code_generator/model/pydantic/base_model.py,sha256=
|
|
14
|
+
datamodel_code_generator/model/pydantic/base_model.py,sha256=Y2GSlcLBvQh8hrlwGE3rGLTsQLKxERBts0so5BcUP6Y,11970
|
|
15
15
|
datamodel_code_generator/model/pydantic/custom_root_type.py,sha256=XOeJqzUEAYE21C3hPAnRIz9iDWIjZvUOWDc9MCrpdvw,299
|
|
16
16
|
datamodel_code_generator/model/pydantic/dataclass.py,sha256=sbqTmutl8Fjf1pYngfdv0NMXt904QcTRpHqmZy6GUiQ,424
|
|
17
17
|
datamodel_code_generator/model/pydantic/imports.py,sha256=2nSLYwphBUMQEa0PTSNwoLjEBslu02EQb6BdZ-S51yk,2189
|
|
@@ -45,15 +45,15 @@ datamodel_code_generator/model/union.py,sha256=loaVWQi-UHkV4gLfF2JhxLcgZRMsejaoJ
|
|
|
45
45
|
datamodel_code_generator/parser/__init__.py,sha256=zHbw6RPlJC0SAQjb-XyVlyZhcOu5PfYgPidy6jlUM8M,793
|
|
46
46
|
datamodel_code_generator/parser/base.py,sha256=SvOqP1C2avQmJAUDDplVhEJJELtLPSnS21-lu-dyn7Y,52714
|
|
47
47
|
datamodel_code_generator/parser/graphql.py,sha256=PuHN3WlCMA0dHuYp0xMmKWHrlhJYryV_LP3831y46YQ,20387
|
|
48
|
-
datamodel_code_generator/parser/jsonschema.py,sha256=
|
|
48
|
+
datamodel_code_generator/parser/jsonschema.py,sha256=3MG0QUt12RFd_lTo6JGQoeJmArbVheJ6dR3nTDRZrBw,69262
|
|
49
49
|
datamodel_code_generator/parser/openapi.py,sha256=Iderij7OytmLchS7EJ6FjCz7rATFp0VlmRz__2uCGvQ,25416
|
|
50
50
|
datamodel_code_generator/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
51
|
datamodel_code_generator/reference.py,sha256=EoalUNUP5us31bfMrHDa1iiKqxL8gHrpZKY_IxgZrOg,26347
|
|
52
52
|
datamodel_code_generator/types.py,sha256=nGUJRwli267SBEhbsAfWIWSf1kDtqGM74Ha-Y05Xvzg,19551
|
|
53
|
-
datamodel_code_generator/util.py,sha256=
|
|
54
|
-
datamodel_code_generator/version.py,sha256=
|
|
55
|
-
datamodel_code_generator-0.25.
|
|
56
|
-
datamodel_code_generator-0.25.
|
|
57
|
-
datamodel_code_generator-0.25.
|
|
58
|
-
datamodel_code_generator-0.25.
|
|
59
|
-
datamodel_code_generator-0.25.
|
|
53
|
+
datamodel_code_generator/util.py,sha256=LCEqSCPsVJkn-aiXltZBcw5G7cQqte9IQnyd0Z8LGrE,3700
|
|
54
|
+
datamodel_code_generator/version.py,sha256=CqzzGug_BFVu7hwUZejterHsBy7pNwfFPjYBYXKyO8g,24
|
|
55
|
+
datamodel_code_generator-0.25.4.dist-info/LICENSE,sha256=K54Lwc6_jduycsy8oFFjQEeSSuEiqvVIjCGIXOMnuTQ,1068
|
|
56
|
+
datamodel_code_generator-0.25.4.dist-info/METADATA,sha256=ukdujdmWa09n01AAkzibHYZ-hffMFPT9F1jdodyCzzQ,22998
|
|
57
|
+
datamodel_code_generator-0.25.4.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
58
|
+
datamodel_code_generator-0.25.4.dist-info/entry_points.txt,sha256=bykbUWqOCiKfxJPGe8jpNqTqD1NG7uyRmozdnwzu7rk,76
|
|
59
|
+
datamodel_code_generator-0.25.4.dist-info/RECORD,,
|
{datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/LICENSE
RENAMED
|
File without changes
|
{datamodel_code_generator-0.25.2.dist-info → datamodel_code_generator-0.25.4.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|