datamodel-code-generator 0.27.2__py3-none-any.whl → 0.27.3__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.

Files changed (43) hide show
  1. datamodel_code_generator/__init__.py +159 -190
  2. datamodel_code_generator/__main__.py +151 -173
  3. datamodel_code_generator/arguments.py +227 -230
  4. datamodel_code_generator/format.py +77 -99
  5. datamodel_code_generator/http.py +9 -10
  6. datamodel_code_generator/imports.py +57 -64
  7. datamodel_code_generator/model/__init__.py +26 -31
  8. datamodel_code_generator/model/base.py +94 -127
  9. datamodel_code_generator/model/dataclass.py +58 -59
  10. datamodel_code_generator/model/enum.py +34 -30
  11. datamodel_code_generator/model/imports.py +13 -11
  12. datamodel_code_generator/model/msgspec.py +112 -126
  13. datamodel_code_generator/model/pydantic/__init__.py +14 -27
  14. datamodel_code_generator/model/pydantic/base_model.py +120 -139
  15. datamodel_code_generator/model/pydantic/custom_root_type.py +2 -2
  16. datamodel_code_generator/model/pydantic/dataclass.py +6 -4
  17. datamodel_code_generator/model/pydantic/imports.py +35 -33
  18. datamodel_code_generator/model/pydantic/types.py +86 -117
  19. datamodel_code_generator/model/pydantic_v2/__init__.py +17 -17
  20. datamodel_code_generator/model/pydantic_v2/base_model.py +118 -119
  21. datamodel_code_generator/model/pydantic_v2/imports.py +5 -3
  22. datamodel_code_generator/model/pydantic_v2/root_model.py +6 -6
  23. datamodel_code_generator/model/pydantic_v2/types.py +8 -7
  24. datamodel_code_generator/model/rootmodel.py +1 -1
  25. datamodel_code_generator/model/scalar.py +33 -32
  26. datamodel_code_generator/model/typed_dict.py +42 -41
  27. datamodel_code_generator/model/types.py +19 -17
  28. datamodel_code_generator/model/union.py +21 -17
  29. datamodel_code_generator/parser/__init__.py +12 -11
  30. datamodel_code_generator/parser/base.py +320 -492
  31. datamodel_code_generator/parser/graphql.py +80 -111
  32. datamodel_code_generator/parser/jsonschema.py +422 -580
  33. datamodel_code_generator/parser/openapi.py +175 -204
  34. datamodel_code_generator/pydantic_patch.py +8 -9
  35. datamodel_code_generator/reference.py +192 -274
  36. datamodel_code_generator/types.py +147 -182
  37. datamodel_code_generator/util.py +22 -26
  38. {datamodel_code_generator-0.27.2.dist-info → datamodel_code_generator-0.27.3.dist-info}/METADATA +7 -1
  39. datamodel_code_generator-0.27.3.dist-info/RECORD +59 -0
  40. datamodel_code_generator-0.27.2.dist-info/RECORD +0 -59
  41. {datamodel_code_generator-0.27.2.dist-info → datamodel_code_generator-0.27.3.dist-info}/WHEEL +0 -0
  42. {datamodel_code_generator-0.27.2.dist-info → datamodel_code_generator-0.27.3.dist-info}/entry_points.txt +0 -0
  43. {datamodel_code_generator-0.27.2.dist-info → datamodel_code_generator-0.27.3.dist-info}/licenses/LICENSE +0 -0
@@ -13,7 +13,7 @@ from datamodel_code_generator.types import StrictTypes
13
13
 
14
14
  if TYPE_CHECKING:
15
15
  from argparse import Action
16
- from typing import Iterable, Optional
16
+ from typing import Iterable
17
17
 
18
18
  DEFAULT_ENCODING = locale.getpreferredencoding()
19
19
 
@@ -21,187 +21,184 @@ namespace = Namespace(no_color=False)
21
21
 
22
22
 
23
23
  class SortingHelpFormatter(HelpFormatter):
24
- def _bold_cyan(self, text: str) -> str:
25
- return f'\x1b[36;1m{text}\x1b[0m'
24
+ def _bold_cyan(self, text: str) -> str: # noqa: PLR6301
25
+ return f"\x1b[36;1m{text}\x1b[0m"
26
26
 
27
27
  def add_arguments(self, actions: Iterable[Action]) -> None:
28
- actions = sorted(actions, key=attrgetter('option_strings'))
28
+ actions = sorted(actions, key=attrgetter("option_strings"))
29
29
  super().add_arguments(actions)
30
30
 
31
- def start_section(self, heading: Optional[str]) -> None:
32
- return super().start_section(
33
- heading if namespace.no_color or not heading else self._bold_cyan(heading)
34
- )
31
+ def start_section(self, heading: str | None) -> None:
32
+ return super().start_section(heading if namespace.no_color or not heading else self._bold_cyan(heading))
35
33
 
36
34
 
37
35
  arg_parser = ArgumentParser(
38
- usage='\n datamodel-codegen [options]',
39
- description='Generate Python data models from schema definitions or structured data',
36
+ usage="\n datamodel-codegen [options]",
37
+ description="Generate Python data models from schema definitions or structured data",
40
38
  formatter_class=SortingHelpFormatter,
41
39
  add_help=False,
42
40
  )
43
41
 
44
- base_options = arg_parser.add_argument_group('Options')
45
- typing_options = arg_parser.add_argument_group('Typing customization')
46
- field_options = arg_parser.add_argument_group('Field customization')
47
- model_options = arg_parser.add_argument_group('Model customization')
48
- template_options = arg_parser.add_argument_group('Template customization')
49
- openapi_options = arg_parser.add_argument_group('OpenAPI-only options')
50
- general_options = arg_parser.add_argument_group('General options')
42
+ base_options = arg_parser.add_argument_group("Options")
43
+ typing_options = arg_parser.add_argument_group("Typing customization")
44
+ field_options = arg_parser.add_argument_group("Field customization")
45
+ model_options = arg_parser.add_argument_group("Model customization")
46
+ template_options = arg_parser.add_argument_group("Template customization")
47
+ openapi_options = arg_parser.add_argument_group("OpenAPI-only options")
48
+ general_options = arg_parser.add_argument_group("General options")
51
49
 
52
50
  # ======================================================================================
53
51
  # Base options for input/output
54
52
  # ======================================================================================
55
53
  base_options.add_argument(
56
- '--http-headers',
57
- nargs='+',
58
- metavar='HTTP_HEADER',
54
+ "--http-headers",
55
+ nargs="+",
56
+ metavar="HTTP_HEADER",
59
57
  help='Set headers in HTTP requests to the remote host. (example: "Authorization: Basic dXNlcjpwYXNz")',
60
58
  )
61
59
  base_options.add_argument(
62
- '--http-query-parameters',
63
- nargs='+',
64
- metavar='HTTP_QUERY_PARAMETERS',
60
+ "--http-query-parameters",
61
+ nargs="+",
62
+ metavar="HTTP_QUERY_PARAMETERS",
65
63
  help='Set query parameters in HTTP requests to the remote host. (example: "ref=branch")',
66
64
  )
67
65
  base_options.add_argument(
68
- '--http-ignore-tls',
66
+ "--http-ignore-tls",
69
67
  help="Disable verification of the remote host's TLS certificate",
70
- action='store_true',
68
+ action="store_true",
71
69
  default=None,
72
70
  )
73
71
  base_options.add_argument(
74
- '--input',
75
- help='Input file/directory (default: stdin)',
72
+ "--input",
73
+ help="Input file/directory (default: stdin)",
76
74
  )
77
75
  base_options.add_argument(
78
- '--input-file-type',
79
- help='Input file type (default: auto)',
76
+ "--input-file-type",
77
+ help="Input file type (default: auto)",
80
78
  choices=[i.value for i in InputFileType],
81
79
  )
82
80
  base_options.add_argument(
83
- '--output',
84
- help='Output file (default: stdout)',
81
+ "--output",
82
+ help="Output file (default: stdout)",
85
83
  )
86
84
  base_options.add_argument(
87
- '--output-model-type',
88
- help='Output model type (default: pydantic.BaseModel)',
85
+ "--output-model-type",
86
+ help="Output model type (default: pydantic.BaseModel)",
89
87
  choices=[i.value for i in DataModelType],
90
88
  )
91
89
  base_options.add_argument(
92
- '--url',
93
- help='Input file URL. `--input` is ignored when `--url` is used',
90
+ "--url",
91
+ help="Input file URL. `--input` is ignored when `--url` is used",
94
92
  )
95
93
 
96
94
  # ======================================================================================
97
95
  # Customization options for generated models
98
96
  # ======================================================================================
99
97
  model_options.add_argument(
100
- '--allow-extra-fields',
101
- help='Allow passing extra fields, if this flag is not passed, extra fields are forbidden.',
102
- action='store_true',
98
+ "--allow-extra-fields",
99
+ help="Allow passing extra fields, if this flag is not passed, extra fields are forbidden.",
100
+ action="store_true",
103
101
  default=None,
104
102
  )
105
103
  model_options.add_argument(
106
- '--allow-population-by-field-name',
107
- help='Allow population by field name',
108
- action='store_true',
104
+ "--allow-population-by-field-name",
105
+ help="Allow population by field name",
106
+ action="store_true",
109
107
  default=None,
110
108
  )
111
109
  model_options.add_argument(
112
- '--class-name',
113
- help='Set class name of root model',
110
+ "--class-name",
111
+ help="Set class name of root model",
114
112
  default=None,
115
113
  )
116
114
  model_options.add_argument(
117
- '--collapse-root-models',
118
- action='store_true',
115
+ "--collapse-root-models",
116
+ action="store_true",
119
117
  default=None,
120
- help='Models generated with a root-type field will be merged '
121
- 'into the models using that root-type model',
118
+ help="Models generated with a root-type field will be merged into the models using that root-type model",
122
119
  )
123
120
  model_options.add_argument(
124
- '--disable-appending-item-suffix',
125
- help='Disable appending `Item` suffix to model name in an array',
126
- action='store_true',
121
+ "--disable-appending-item-suffix",
122
+ help="Disable appending `Item` suffix to model name in an array",
123
+ action="store_true",
127
124
  default=None,
128
125
  )
129
126
  model_options.add_argument(
130
- '--disable-timestamp',
131
- help='Disable timestamp on file headers',
132
- action='store_true',
127
+ "--disable-timestamp",
128
+ help="Disable timestamp on file headers",
129
+ action="store_true",
133
130
  default=None,
134
131
  )
135
132
  model_options.add_argument(
136
- '--enable-faux-immutability',
137
- help='Enable faux immutability',
138
- action='store_true',
133
+ "--enable-faux-immutability",
134
+ help="Enable faux immutability",
135
+ action="store_true",
139
136
  default=None,
140
137
  )
141
138
  model_options.add_argument(
142
- '--enable-version-header',
143
- help='Enable package version on file headers',
144
- action='store_true',
139
+ "--enable-version-header",
140
+ help="Enable package version on file headers",
141
+ action="store_true",
145
142
  default=None,
146
143
  )
147
144
  model_options.add_argument(
148
- '--keep-model-order',
145
+ "--keep-model-order",
149
146
  help="Keep generated models' order",
150
- action='store_true',
147
+ action="store_true",
151
148
  default=None,
152
149
  )
153
150
  model_options.add_argument(
154
- '--keyword-only',
155
- help='Defined models as keyword only (for example dataclass(kw_only=True)).',
156
- action='store_true',
151
+ "--keyword-only",
152
+ help="Defined models as keyword only (for example dataclass(kw_only=True)).",
153
+ action="store_true",
157
154
  default=None,
158
155
  )
159
156
  model_options.add_argument(
160
- '--reuse-model',
161
- help='Reuse models on the field when a module has the model with the same content',
162
- action='store_true',
157
+ "--reuse-model",
158
+ help="Reuse models on the field when a module has the model with the same content",
159
+ action="store_true",
163
160
  default=None,
164
161
  )
165
162
  model_options.add_argument(
166
- '--target-python-version',
167
- help='target python version (default: 3.8)',
163
+ "--target-python-version",
164
+ help="target python version (default: 3.8)",
168
165
  choices=[v.value for v in PythonVersion],
169
166
  )
170
167
  model_options.add_argument(
171
- '--treat-dot-as-module',
172
- help='treat dotted module names as modules',
173
- action='store_true',
168
+ "--treat-dot-as-module",
169
+ help="treat dotted module names as modules",
170
+ action="store_true",
174
171
  default=False,
175
172
  )
176
173
  model_options.add_argument(
177
- '--use-schema-description',
178
- help='Use schema description to populate class docstring',
179
- action='store_true',
174
+ "--use-schema-description",
175
+ help="Use schema description to populate class docstring",
176
+ action="store_true",
180
177
  default=None,
181
178
  )
182
179
  model_options.add_argument(
183
- '--use-title-as-name',
184
- help='use titles as class names of models',
185
- action='store_true',
180
+ "--use-title-as-name",
181
+ help="use titles as class names of models",
182
+ action="store_true",
186
183
  default=None,
187
184
  )
188
185
  model_options.add_argument(
189
- '--use-pendulum',
190
- help='use pendulum instead of datetime',
191
- action='store_true',
186
+ "--use-pendulum",
187
+ help="use pendulum instead of datetime",
188
+ action="store_true",
192
189
  default=False,
193
190
  )
194
191
  model_options.add_argument(
195
- '--use-exact-imports',
192
+ "--use-exact-imports",
196
193
  help='import exact types instead of modules, for example: "from .foo import Bar" instead of '
197
194
  '"from . import foo" with "foo.Bar"',
198
- action='store_true',
195
+ action="store_true",
199
196
  default=False,
200
197
  )
201
198
  model_options.add_argument(
202
- '--output-datetime-class',
203
- help='Choose Datetime class between AwareDatetime, NaiveDatetime or datetime. '
204
- 'Each output model has its default mapping (for example pydantic: datetime, dataclass: str, ...)',
199
+ "--output-datetime-class",
200
+ help="Choose Datetime class between AwareDatetime, NaiveDatetime or datetime. "
201
+ "Each output model has its default mapping (for example pydantic: datetime, dataclass: str, ...)",
205
202
  choices=[i.value for i in DatetimeClassType],
206
203
  default=None,
207
204
  )
@@ -210,83 +207,83 @@ model_options.add_argument(
210
207
  # Typing options for generated models
211
208
  # ======================================================================================
212
209
  typing_options.add_argument(
213
- '--base-class',
214
- help='Base Class (default: pydantic.BaseModel)',
210
+ "--base-class",
211
+ help="Base Class (default: pydantic.BaseModel)",
215
212
  type=str,
216
213
  )
217
214
  typing_options.add_argument(
218
- '--enum-field-as-literal',
219
- help='Parse enum field as literal. '
220
- 'all: all enum field type are Literal. '
221
- 'one: field type is Literal when an enum has only one possible value',
215
+ "--enum-field-as-literal",
216
+ help="Parse enum field as literal. "
217
+ "all: all enum field type are Literal. "
218
+ "one: field type is Literal when an enum has only one possible value",
222
219
  choices=[lt.value for lt in LiteralType],
223
220
  default=None,
224
221
  )
225
222
  typing_options.add_argument(
226
- '--field-constraints',
227
- help='Use field constraints and not con* annotations',
228
- action='store_true',
223
+ "--field-constraints",
224
+ help="Use field constraints and not con* annotations",
225
+ action="store_true",
229
226
  default=None,
230
227
  )
231
228
  typing_options.add_argument(
232
- '--set-default-enum-member',
233
- help='Set enum members as default values for enum field',
234
- action='store_true',
229
+ "--set-default-enum-member",
230
+ help="Set enum members as default values for enum field",
231
+ action="store_true",
235
232
  default=None,
236
233
  )
237
234
  typing_options.add_argument(
238
- '--strict-types',
239
- help='Use strict types',
235
+ "--strict-types",
236
+ help="Use strict types",
240
237
  choices=[t.value for t in StrictTypes],
241
- nargs='+',
238
+ nargs="+",
242
239
  )
243
240
  typing_options.add_argument(
244
- '--use-annotated',
245
- help='Use typing.Annotated for Field(). Also, `--field-constraints` option will be enabled.',
246
- action='store_true',
241
+ "--use-annotated",
242
+ help="Use typing.Annotated for Field(). Also, `--field-constraints` option will be enabled.",
243
+ action="store_true",
247
244
  default=None,
248
245
  )
249
246
  typing_options.add_argument(
250
- '--use-generic-container-types',
251
- help='Use generic container types for type hinting (typing.Sequence, typing.Mapping). '
252
- 'If `--use-standard-collections` option is set, then import from collections.abc instead of typing',
253
- action='store_true',
247
+ "--use-generic-container-types",
248
+ help="Use generic container types for type hinting (typing.Sequence, typing.Mapping). "
249
+ "If `--use-standard-collections` option is set, then import from collections.abc instead of typing",
250
+ action="store_true",
254
251
  default=None,
255
252
  )
256
253
  typing_options.add_argument(
257
- '--use-non-positive-negative-number-constrained-types',
258
- help='Use the Non{Positive,Negative}{FloatInt} types instead of the corresponding con* constrained types.',
259
- action='store_true',
254
+ "--use-non-positive-negative-number-constrained-types",
255
+ help="Use the Non{Positive,Negative}{FloatInt} types instead of the corresponding con* constrained types.",
256
+ action="store_true",
260
257
  default=None,
261
258
  )
262
259
  typing_options.add_argument(
263
- '--use-one-literal-as-default',
264
- help='Use one literal as default value for one literal field',
265
- action='store_true',
260
+ "--use-one-literal-as-default",
261
+ help="Use one literal as default value for one literal field",
262
+ action="store_true",
266
263
  default=None,
267
264
  )
268
265
  typing_options.add_argument(
269
- '--use-standard-collections',
270
- help='Use standard collections for type hinting (list, dict)',
271
- action='store_true',
266
+ "--use-standard-collections",
267
+ help="Use standard collections for type hinting (list, dict)",
268
+ action="store_true",
272
269
  default=None,
273
270
  )
274
271
  typing_options.add_argument(
275
- '--use-subclass-enum',
276
- help='Define Enum class as subclass with field type when enum has type (int, float, bytes, str)',
277
- action='store_true',
272
+ "--use-subclass-enum",
273
+ help="Define Enum class as subclass with field type when enum has type (int, float, bytes, str)",
274
+ action="store_true",
278
275
  default=None,
279
276
  )
280
277
  typing_options.add_argument(
281
- '--use-union-operator',
282
- help='Use | operator for Union type (PEP 604).',
283
- action='store_true',
278
+ "--use-union-operator",
279
+ help="Use | operator for Union type (PEP 604).",
280
+ action="store_true",
284
281
  default=None,
285
282
  )
286
283
  typing_options.add_argument(
287
- '--use-unique-items-as-set',
288
- help='define field type as `set` when the field attribute has `uniqueItems`',
289
- action='store_true',
284
+ "--use-unique-items-as-set",
285
+ help="define field type as `set` when the field attribute has `uniqueItems`",
286
+ action="store_true",
290
287
  default=None,
291
288
  )
292
289
 
@@ -294,98 +291,98 @@ typing_options.add_argument(
294
291
  # Customization options for generated model fields
295
292
  # ======================================================================================
296
293
  field_options.add_argument(
297
- '--capitalise-enum-members',
298
- '--capitalize-enum-members',
299
- help='Capitalize field names on enum',
300
- action='store_true',
294
+ "--capitalise-enum-members",
295
+ "--capitalize-enum-members",
296
+ help="Capitalize field names on enum",
297
+ action="store_true",
301
298
  default=None,
302
299
  )
303
300
  field_options.add_argument(
304
- '--empty-enum-field-name',
305
- help='Set field name when enum value is empty (default: `_`)',
301
+ "--empty-enum-field-name",
302
+ help="Set field name when enum value is empty (default: `_`)",
306
303
  default=None,
307
304
  )
308
305
  field_options.add_argument(
309
- '--field-extra-keys',
310
- help='Add extra keys to field parameters',
306
+ "--field-extra-keys",
307
+ help="Add extra keys to field parameters",
311
308
  type=str,
312
- nargs='+',
309
+ nargs="+",
313
310
  )
314
311
  field_options.add_argument(
315
- '--field-extra-keys-without-x-prefix',
316
- help='Add extra keys with `x-` prefix to field parameters. The extra keys are stripped of the `x-` prefix.',
312
+ "--field-extra-keys-without-x-prefix",
313
+ help="Add extra keys with `x-` prefix to field parameters. The extra keys are stripped of the `x-` prefix.",
317
314
  type=str,
318
- nargs='+',
315
+ nargs="+",
319
316
  )
320
317
  field_options.add_argument(
321
- '--field-include-all-keys',
322
- help='Add all keys to field parameters',
323
- action='store_true',
318
+ "--field-include-all-keys",
319
+ help="Add all keys to field parameters",
320
+ action="store_true",
324
321
  default=None,
325
322
  )
326
323
  field_options.add_argument(
327
- '--force-optional',
328
- help='Force optional for required fields',
329
- action='store_true',
324
+ "--force-optional",
325
+ help="Force optional for required fields",
326
+ action="store_true",
330
327
  default=None,
331
328
  )
332
329
  field_options.add_argument(
333
- '--original-field-name-delimiter',
334
- help='Set delimiter to convert to snake case. This option only can be used with --snake-case-field (default: `_` )',
330
+ "--original-field-name-delimiter",
331
+ help="Set delimiter to convert to snake case. This option only can be used with --snake-case-field (default: `_` )",
335
332
  default=None,
336
333
  )
337
334
  field_options.add_argument(
338
- '--remove-special-field-name-prefix',
339
- help='Remove field name prefix if it has a special meaning e.g. underscores',
340
- action='store_true',
335
+ "--remove-special-field-name-prefix",
336
+ help="Remove field name prefix if it has a special meaning e.g. underscores",
337
+ action="store_true",
341
338
  default=None,
342
339
  )
343
340
  field_options.add_argument(
344
- '--snake-case-field',
345
- help='Change camel-case field name to snake-case',
346
- action='store_true',
341
+ "--snake-case-field",
342
+ help="Change camel-case field name to snake-case",
343
+ action="store_true",
347
344
  default=None,
348
345
  )
349
346
  field_options.add_argument(
350
- '--special-field-name-prefix',
347
+ "--special-field-name-prefix",
351
348
  help="Set field name prefix when first character can't be used as Python field name (default: `field`)",
352
349
  default=None,
353
350
  )
354
351
  field_options.add_argument(
355
- '--strip-default-none',
356
- help='Strip default None on fields',
357
- action='store_true',
352
+ "--strip-default-none",
353
+ help="Strip default None on fields",
354
+ action="store_true",
358
355
  default=None,
359
356
  )
360
357
  field_options.add_argument(
361
- '--use-default',
362
- help='Use default value even if a field is required',
363
- action='store_true',
358
+ "--use-default",
359
+ help="Use default value even if a field is required",
360
+ action="store_true",
364
361
  default=None,
365
362
  )
366
363
  field_options.add_argument(
367
- '--use-default-kwarg',
368
- action='store_true',
369
- help='Use `default=` instead of a positional argument for Fields that have default values.',
364
+ "--use-default-kwarg",
365
+ action="store_true",
366
+ help="Use `default=` instead of a positional argument for Fields that have default values.",
370
367
  default=None,
371
368
  )
372
369
  field_options.add_argument(
373
- '--use-field-description',
374
- help='Use schema description to populate field docstring',
375
- action='store_true',
370
+ "--use-field-description",
371
+ help="Use schema description to populate field docstring",
372
+ action="store_true",
376
373
  default=None,
377
374
  )
378
375
  field_options.add_argument(
379
- '--union-mode',
380
- help='Union mode for only pydantic v2 field',
376
+ "--union-mode",
377
+ help="Union mode for only pydantic v2 field",
381
378
  choices=[u.value for u in UnionMode],
382
379
  default=None,
383
380
  )
384
381
  field_options.add_argument(
385
- '--no-alias',
386
- help="""Do not add a field alias. E.g., if --snake-case-field is used along with a base class, which has an
382
+ "--no-alias",
383
+ help="""Do not add a field alias. E.g., if --snake-case-field is used along with a base class, which has an
387
384
  alias_generator""",
388
- action='store_true',
385
+ action="store_true",
389
386
  default=None,
390
387
  )
391
388
 
@@ -393,95 +390,95 @@ field_options.add_argument(
393
390
  # Options for templating output
394
391
  # ======================================================================================
395
392
  template_options.add_argument(
396
- '--aliases',
397
- help='Alias mapping file',
398
- type=FileType('rt'),
393
+ "--aliases",
394
+ help="Alias mapping file",
395
+ type=FileType("rt"),
399
396
  )
400
397
  template_options.add_argument(
401
- '--custom-file-header',
402
- help='Custom file header',
398
+ "--custom-file-header",
399
+ help="Custom file header",
403
400
  type=str,
404
401
  default=None,
405
402
  )
406
403
  template_options.add_argument(
407
- '--custom-file-header-path',
408
- help='Custom file header file path',
404
+ "--custom-file-header-path",
405
+ help="Custom file header file path",
409
406
  default=None,
410
407
  type=str,
411
408
  )
412
409
  template_options.add_argument(
413
- '--custom-template-dir',
414
- help='Custom template directory',
410
+ "--custom-template-dir",
411
+ help="Custom template directory",
415
412
  type=str,
416
413
  )
417
414
  template_options.add_argument(
418
- '--encoding',
419
- help=f'The encoding of input and output (default: {DEFAULT_ENCODING})',
415
+ "--encoding",
416
+ help=f"The encoding of input and output (default: {DEFAULT_ENCODING})",
420
417
  default=None,
421
418
  )
422
419
  template_options.add_argument(
423
- '--extra-template-data',
424
- help='Extra template data',
425
- type=FileType('rt'),
420
+ "--extra-template-data",
421
+ help="Extra template data",
422
+ type=FileType("rt"),
426
423
  )
427
424
  template_options.add_argument(
428
- '--use-double-quotes',
429
- action='store_true',
425
+ "--use-double-quotes",
426
+ action="store_true",
430
427
  default=None,
431
- help='Model generated with double quotes. Single quotes or '
432
- 'your black config skip_string_normalization value will be used without this option.',
428
+ help="Model generated with double quotes. Single quotes or "
429
+ "your black config skip_string_normalization value will be used without this option.",
433
430
  )
434
431
  template_options.add_argument(
435
- '--wrap-string-literal',
436
- help='Wrap string literal by using black `experimental-string-processing` option (require black 20.8b0 or later)',
437
- action='store_true',
432
+ "--wrap-string-literal",
433
+ help="Wrap string literal by using black `experimental-string-processing` option (require black 20.8b0 or later)",
434
+ action="store_true",
438
435
  default=None,
439
436
  )
440
437
  base_options.add_argument(
441
- '--additional-imports',
438
+ "--additional-imports",
442
439
  help='Custom imports for output (delimited list input). For example "datetime.date,datetime.datetime"',
443
440
  type=str,
444
441
  default=None,
445
442
  )
446
443
  base_options.add_argument(
447
- '--custom-formatters',
448
- help='List of modules with custom formatter (delimited list input).',
444
+ "--custom-formatters",
445
+ help="List of modules with custom formatter (delimited list input).",
449
446
  type=str,
450
447
  default=None,
451
448
  )
452
449
  template_options.add_argument(
453
- '--custom-formatters-kwargs',
454
- help='A file with kwargs for custom formatters.',
455
- type=FileType('rt'),
450
+ "--custom-formatters-kwargs",
451
+ help="A file with kwargs for custom formatters.",
452
+ type=FileType("rt"),
456
453
  )
457
454
 
458
455
  # ======================================================================================
459
456
  # Options specific to OpenAPI input schemas
460
457
  # ======================================================================================
461
458
  openapi_options.add_argument(
462
- '--openapi-scopes',
463
- help='Scopes of OpenAPI model generation (default: schemas)',
459
+ "--openapi-scopes",
460
+ help="Scopes of OpenAPI model generation (default: schemas)",
464
461
  choices=[o.value for o in OpenAPIScope],
465
- nargs='+',
462
+ nargs="+",
466
463
  default=None,
467
464
  )
468
465
  openapi_options.add_argument(
469
- '--strict-nullable',
470
- help='Treat default field as a non-nullable field (Only OpenAPI)',
471
- action='store_true',
466
+ "--strict-nullable",
467
+ help="Treat default field as a non-nullable field (Only OpenAPI)",
468
+ action="store_true",
472
469
  default=None,
473
470
  )
474
471
  openapi_options.add_argument(
475
- '--use-operation-id-as-name',
476
- help='use operation id of OpenAPI as class names of models',
477
- action='store_true',
472
+ "--use-operation-id-as-name",
473
+ help="use operation id of OpenAPI as class names of models",
474
+ action="store_true",
478
475
  default=None,
479
476
  )
480
477
  openapi_options.add_argument(
481
- '--validation',
482
- help='Deprecated: Enable validation (Only OpenAPI). this option is deprecated. it will be removed in future '
483
- 'releases',
484
- action='store_true',
478
+ "--validation",
479
+ help="Deprecated: Enable validation (Only OpenAPI). this option is deprecated. it will be removed in future "
480
+ "releases",
481
+ action="store_true",
485
482
  default=None,
486
483
  )
487
484
 
@@ -489,38 +486,38 @@ openapi_options.add_argument(
489
486
  # General options
490
487
  # ======================================================================================
491
488
  general_options.add_argument(
492
- '--debug',
493
- help='show debug message (require "debug". `$ pip install \'datamodel-code-generator[debug]\'`)',
494
- action='store_true',
489
+ "--debug",
490
+ help="show debug message (require \"debug\". `$ pip install 'datamodel-code-generator[debug]'`)",
491
+ action="store_true",
495
492
  default=None,
496
493
  )
497
494
  general_options.add_argument(
498
- '--disable-warnings',
499
- help='disable warnings',
500
- action='store_true',
495
+ "--disable-warnings",
496
+ help="disable warnings",
497
+ action="store_true",
501
498
  default=None,
502
499
  )
503
500
  general_options.add_argument(
504
- '-h',
505
- '--help',
506
- action='help',
507
- default='==SUPPRESS==',
508
- help='show this help message and exit',
501
+ "-h",
502
+ "--help",
503
+ action="help",
504
+ default="==SUPPRESS==",
505
+ help="show this help message and exit",
509
506
  )
510
507
  general_options.add_argument(
511
- '--no-color',
512
- action='store_true',
508
+ "--no-color",
509
+ action="store_true",
513
510
  default=False,
514
- help='disable colorized output',
511
+ help="disable colorized output",
515
512
  )
516
513
  general_options.add_argument(
517
- '--version',
518
- action='store_true',
519
- help='show version',
514
+ "--version",
515
+ action="store_true",
516
+ help="show version",
520
517
  )
521
518
 
522
519
  __all__ = [
523
- 'arg_parser',
524
- 'DEFAULT_ENCODING',
525
- 'namespace',
520
+ "DEFAULT_ENCODING",
521
+ "arg_parser",
522
+ "namespace",
526
523
  ]