openapi-python-client 0.24.3__tar.gz → 0.25.1__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.
Files changed (114) hide show
  1. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/PKG-INFO +4 -4
  2. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/cli.py +2 -4
  3. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/any.py +1 -1
  4. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/const.py +0 -1
  5. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/file.py +2 -2
  6. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/list_property.py +1 -4
  7. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/model_property.py +3 -6
  8. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/protocol.py +1 -5
  9. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/schemas.py +1 -1
  10. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/union.py +9 -12
  11. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/endpoint_macros.py.jinja +10 -10
  12. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/endpoint_module.py.jinja +2 -5
  13. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/model.py.jinja +46 -18
  14. openapi_python_client-0.25.1/openapi_python_client/templates/property_templates/any_property.py.jinja +3 -0
  15. openapi_python_client-0.25.1/openapi_python_client/templates/property_templates/boolean_property.py.jinja +7 -0
  16. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/const_property.py.jinja +4 -0
  17. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/date_property.py.jinja +2 -10
  18. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/datetime_property.py.jinja +2 -10
  19. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/enum_property.py.jinja +3 -11
  20. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/file_property.py.jinja +2 -8
  21. openapi_python_client-0.25.1/openapi_python_client/templates/property_templates/float_property.py.jinja +7 -0
  22. openapi_python_client-0.25.1/openapi_python_client/templates/property_templates/int_property.py.jinja +7 -0
  23. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/list_property.py.jinja +8 -31
  24. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja +3 -11
  25. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/model_property.py.jinja +7 -17
  26. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/union_property.py.jinja +18 -15
  27. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/uuid_property.py.jinja +2 -9
  28. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/pyproject.toml.jinja +2 -2
  29. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/setup.py.jinja +1 -1
  30. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/types.py.jinja +13 -7
  31. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/pyproject.toml +5 -5
  32. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/any_property.py.jinja +0 -7
  33. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/boolean_property.py.jinja +0 -11
  34. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/float_property.py.jinja +0 -11
  35. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/int_property.py.jinja +0 -11
  36. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/.gitignore +0 -0
  37. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/LICENSE +0 -0
  38. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/README.md +0 -0
  39. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/__init__.py +0 -0
  40. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/__main__.py +0 -0
  41. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/config.py +0 -0
  42. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/__init__.py +0 -0
  43. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/bodies.py +0 -0
  44. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/errors.py +0 -0
  45. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/openapi.py +0 -0
  46. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/__init__.py +0 -0
  47. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/boolean.py +0 -0
  48. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/date.py +0 -0
  49. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/datetime.py +0 -0
  50. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/enum_property.py +0 -0
  51. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/float.py +0 -0
  52. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/int.py +0 -0
  53. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/literal_enum_property.py +0 -0
  54. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/merge_properties.py +0 -0
  55. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/none.py +0 -0
  56. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/property.py +0 -0
  57. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/string.py +0 -0
  58. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/properties/uuid.py +0 -0
  59. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/parser/responses.py +0 -0
  60. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/py.typed +0 -0
  61. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/3.0.3.md +0 -0
  62. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/3.1.0.md +0 -0
  63. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/__init__.py +0 -0
  64. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/data_type.py +0 -0
  65. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/LICENSE +0 -0
  66. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/README.md +0 -0
  67. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/__init__.py +0 -0
  68. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/callback.py +0 -0
  69. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/components.py +0 -0
  70. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/contact.py +0 -0
  71. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/discriminator.py +0 -0
  72. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/encoding.py +0 -0
  73. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/example.py +0 -0
  74. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py +0 -0
  75. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/header.py +0 -0
  76. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/info.py +0 -0
  77. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/license.py +0 -0
  78. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/link.py +0 -0
  79. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/media_type.py +0 -0
  80. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py +0 -0
  81. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/oauth_flows.py +0 -0
  82. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/open_api.py +0 -0
  83. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/operation.py +0 -0
  84. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/parameter.py +0 -0
  85. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/path_item.py +0 -0
  86. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/paths.py +0 -0
  87. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/reference.py +0 -0
  88. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/request_body.py +0 -0
  89. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/response.py +0 -0
  90. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/responses.py +0 -0
  91. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/schema.py +0 -0
  92. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py +0 -0
  93. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py +0 -0
  94. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/server.py +0 -0
  95. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/server_variable.py +0 -0
  96. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/tag.py +0 -0
  97. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/openapi_schema_pydantic/xml.py +0 -0
  98. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/schema/parameter_location.py +0 -0
  99. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/.gitignore.jinja +0 -0
  100. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/README.md.jinja +0 -0
  101. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/api_init.py.jinja +0 -0
  102. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/client.py.jinja +0 -0
  103. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/endpoint_init.py.jinja +0 -0
  104. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/errors.py.jinja +0 -0
  105. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/helpers.jinja +0 -0
  106. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/int_enum.py.jinja +0 -0
  107. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/literal_enum.py.jinja +0 -0
  108. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/models_init.py.jinja +0 -0
  109. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/package_init.py.jinja +0 -0
  110. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/helpers.jinja +0 -0
  111. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/property_templates/property_macros.py.jinja +0 -0
  112. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/pyproject_ruff.toml.jinja +0 -0
  113. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/templates/str_enum.py.jinja +0 -0
  114. {openapi_python_client-0.24.3 → openapi_python_client-0.25.1}/openapi_python_client/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openapi-python-client
3
- Version: 0.24.3
3
+ Version: 0.25.1
4
4
  Summary: Generate modern Python clients from OpenAPI
5
5
  Project-URL: repository, https://github.com/openapi-generators/openapi-python-client
6
6
  Author-email: Dylan Anthony <contact@dylananthony.com>
@@ -21,14 +21,14 @@ Classifier: Typing :: Typed
21
21
  Requires-Python: <4.0,>=3.9
22
22
  Requires-Dist: attrs>=22.2.0
23
23
  Requires-Dist: colorama>=0.4.3; sys_platform == 'win32'
24
- Requires-Dist: httpx<0.29.0,>=0.20.0
24
+ Requires-Dist: httpx<0.29.0,>=0.23.0
25
25
  Requires-Dist: jinja2<4.0.0,>=3.0.0
26
26
  Requires-Dist: pydantic<3.0.0,>=2.10
27
27
  Requires-Dist: python-dateutil<3.0.0,>=2.8.1
28
28
  Requires-Dist: ruamel-yaml<0.19.0,>=0.18.6
29
- Requires-Dist: ruff<0.12,>=0.2
29
+ Requires-Dist: ruff<0.13,>=0.2
30
30
  Requires-Dist: shellingham<2.0.0,>=1.3.2
31
- Requires-Dist: typer<0.16,>0.6
31
+ Requires-Dist: typer<0.17,>0.6
32
32
  Requires-Dist: typing-extensions<5.0.0,>=4.8.0
33
33
  Description-Content-Type: text/markdown
34
34
 
@@ -6,7 +6,7 @@ from typing import Optional, Union
6
6
 
7
7
  import typer
8
8
 
9
- from openapi_python_client import MetaType
9
+ from openapi_python_client import MetaType, __version__
10
10
  from openapi_python_client.config import Config, ConfigFile
11
11
  from openapi_python_client.parser.errors import ErrorLevel, GeneratorError, ParseError
12
12
 
@@ -14,8 +14,6 @@ app = typer.Typer(name="openapi-python-client")
14
14
 
15
15
 
16
16
  def _version_callback(value: bool) -> None:
17
- from openapi_python_client import __version__
18
-
19
17
  if value:
20
18
  typer.echo(f"openapi-python-client version: {__version__}")
21
19
  raise typer.Exit()
@@ -153,7 +151,7 @@ def generate(
153
151
  ),
154
152
  ) -> None:
155
153
  """Generate a new OpenAPI Client library"""
156
- from . import generate
154
+ from . import generate # noqa: PLC0415
157
155
 
158
156
  config = _process_config(
159
157
  url=url,
@@ -33,7 +33,7 @@ class AnyProperty(PropertyProtocol):
33
33
 
34
34
  @classmethod
35
35
  def convert_value(cls, value: Any) -> Value | None:
36
- from .string import StringProperty
36
+ from .string import StringProperty # noqa: PLC0415
37
37
 
38
38
  if value is None:
39
39
  return value
@@ -94,7 +94,6 @@ class ConstProperty(PropertyProtocol):
94
94
  no_optional: bool = False,
95
95
  json: bool = False,
96
96
  *,
97
- multipart: bool = False,
98
97
  quoted: bool = False,
99
98
  ) -> str:
100
99
  lit = f"Literal[{self.value.python_code}]"
@@ -22,7 +22,7 @@ class FileProperty(PropertyProtocol):
22
22
 
23
23
  _type_string: ClassVar[str] = "File"
24
24
  # Return type of File.to_tuple()
25
- _json_type_string: ClassVar[str] = "FileJsonType"
25
+ _json_type_string: ClassVar[str] = "types.FileTypes"
26
26
  template: ClassVar[str] = "file_property.py.jinja"
27
27
 
28
28
  @classmethod
@@ -63,5 +63,5 @@ class FileProperty(PropertyProtocol):
63
63
  back to the root of the generated client.
64
64
  """
65
65
  imports = super().get_imports(prefix=prefix)
66
- imports.update({f"from {prefix}types import File, FileJsonType", "from io import BytesIO"})
66
+ imports.update({f"from {prefix}types import File, FileTypes", "from io import BytesIO"})
67
67
  return imports
@@ -56,7 +56,7 @@ class ListProperty(PropertyProtocol):
56
56
  `(result, schemas)` where `schemas` is an updated version of the input named the same including any inner
57
57
  classes that were defined and `result` is either the `ListProperty` or a `PropertyError`.
58
58
  """
59
- from . import property_from_data
59
+ from . import property_from_data # noqa: PLC0415
60
60
 
61
61
  if data.items is None and not data.prefixItems:
62
62
  return (
@@ -138,7 +138,6 @@ class ListProperty(PropertyProtocol):
138
138
  no_optional: bool = False,
139
139
  json: bool = False,
140
140
  *,
141
- multipart: bool = False,
142
141
  quoted: bool = False,
143
142
  ) -> str:
144
143
  """
@@ -150,8 +149,6 @@ class ListProperty(PropertyProtocol):
150
149
  """
151
150
  if json:
152
151
  type_string = self.get_base_json_type_string()
153
- elif multipart:
154
- type_string = "tuple[None, bytes, str]"
155
152
  else:
156
153
  type_string = self.get_base_type_string()
157
154
 
@@ -189,7 +189,6 @@ class ModelProperty(PropertyProtocol):
189
189
  no_optional: bool = False,
190
190
  json: bool = False,
191
191
  *,
192
- multipart: bool = False,
193
192
  quoted: bool = False,
194
193
  ) -> str:
195
194
  """
@@ -201,8 +200,6 @@ class ModelProperty(PropertyProtocol):
201
200
  """
202
201
  if json:
203
202
  type_string = self.get_base_json_type_string()
204
- elif multipart:
205
- type_string = "tuple[None, bytes, str]"
206
203
  else:
207
204
  type_string = self.get_base_type_string()
208
205
 
@@ -245,8 +242,8 @@ def _process_properties( # noqa: PLR0912, PLR0911
245
242
  config: Config,
246
243
  roots: set[ReferencePath | utils.ClassName],
247
244
  ) -> _PropertyData | PropertyError:
248
- from . import property_from_data
249
- from .merge_properties import merge_properties
245
+ from . import property_from_data # noqa: PLC0415
246
+ from .merge_properties import merge_properties # noqa: PLC0415
250
247
 
251
248
  properties: dict[str, Property] = {}
252
249
  relative_imports: set[str] = set()
@@ -356,7 +353,7 @@ def _get_additional_properties(
356
353
  config: Config,
357
354
  roots: set[ReferencePath | utils.ClassName],
358
355
  ) -> tuple[Property | None | PropertyError, Schemas]:
359
- from . import property_from_data
356
+ from . import property_from_data # noqa: PLC0415
360
357
 
361
358
  if schema_additional is None:
362
359
  return ANY_ADDITIONAL_PROPERTY, schemas
@@ -101,7 +101,6 @@ class PropertyProtocol(Protocol):
101
101
  no_optional: bool = False,
102
102
  json: bool = False,
103
103
  *,
104
- multipart: bool = False,
105
104
  quoted: bool = False,
106
105
  ) -> str:
107
106
  """
@@ -110,13 +109,10 @@ class PropertyProtocol(Protocol):
110
109
  Args:
111
110
  no_optional: Do not include Optional or Unset even if the value is optional (needed for isinstance checks)
112
111
  json: True if the type refers to the property after JSON serialization
113
- multipart: True if the type should be used in a multipart request
114
112
  quoted: True if the type should be wrapped in quotes (if not a base type)
115
113
  """
116
114
  if json:
117
115
  type_string = self.get_base_json_type_string(quoted=quoted)
118
- elif multipart:
119
- type_string = "tuple[None, bytes, str]"
120
116
  else:
121
117
  type_string = self.get_base_type_string(quoted=quoted)
122
118
 
@@ -178,7 +174,7 @@ class PropertyProtocol(Protocol):
178
174
  @property
179
175
  def is_base_type(self) -> bool:
180
176
  """Base types, represented by any other of `Property` than `ModelProperty` should not be quoted."""
181
- from . import ListProperty, ModelProperty, UnionProperty
177
+ from . import ListProperty, ModelProperty, UnionProperty # noqa: PLC0415
182
178
 
183
179
  return self.__class__.__name__ not in {
184
180
  ModelProperty.__name__,
@@ -118,7 +118,7 @@ def update_schemas_with_data(
118
118
  See Also:
119
119
  - https://swagger.io/docs/specification/using-ref/
120
120
  """
121
- from . import property_from_data
121
+ from . import property_from_data # noqa: PLC0415
122
122
 
123
123
  prop: Union[PropertyError, Property]
124
124
  prop, schemas = property_from_data(
@@ -45,7 +45,7 @@ class UnionProperty(PropertyProtocol):
45
45
  `(result, schemas)` where `schemas` is the updated version of the input `schemas` and `result` is the
46
46
  constructed `UnionProperty` or a `PropertyError` describing what went wrong.
47
47
  """
48
- from . import property_from_data
48
+ from . import property_from_data # noqa: PLC0415
49
49
 
50
50
  sub_properties: list[PropertyProtocol] = []
51
51
 
@@ -106,10 +106,9 @@ class UnionProperty(PropertyProtocol):
106
106
  return value_or_error
107
107
  return value_or_error
108
108
 
109
- def _get_inner_type_strings(self, json: bool, multipart: bool) -> set[str]:
109
+ def _get_inner_type_strings(self, json: bool) -> set[str]:
110
110
  return {
111
- p.get_type_string(no_optional=True, json=json, multipart=multipart, quoted=not p.is_base_type)
112
- for p in self.inner_properties
111
+ p.get_type_string(no_optional=True, json=json, quoted=not p.is_base_type) for p in self.inner_properties
113
112
  }
114
113
 
115
114
  @staticmethod
@@ -119,12 +118,12 @@ class UnionProperty(PropertyProtocol):
119
118
  return f"Union[{', '.join(sorted(inner_types))}]"
120
119
 
121
120
  def get_base_type_string(self, *, quoted: bool = False) -> str:
122
- return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=False, multipart=False))
121
+ return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=False))
123
122
 
124
123
  def get_base_json_type_string(self, *, quoted: bool = False) -> str:
125
- return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=True, multipart=False))
124
+ return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=True))
126
125
 
127
- def get_type_strings_in_union(self, *, no_optional: bool = False, json: bool, multipart: bool) -> set[str]:
126
+ def get_type_strings_in_union(self, *, no_optional: bool = False, json: bool) -> set[str]:
128
127
  """
129
128
  Get the set of all the types that should appear within the `Union` representing this property.
130
129
 
@@ -133,12 +132,11 @@ class UnionProperty(PropertyProtocol):
133
132
  Args:
134
133
  no_optional: Do not include `None` or `Unset` in this set.
135
134
  json: If True, this returns the JSON types, not the Python types, of this property.
136
- multipart: If True, this returns the multipart types, not the Python types, of this property.
137
135
 
138
136
  Returns:
139
137
  A set of strings containing the types that should appear within `Union`.
140
138
  """
141
- type_strings = self._get_inner_type_strings(json=json, multipart=multipart)
139
+ type_strings = self._get_inner_type_strings(json=json)
142
140
  if no_optional:
143
141
  return type_strings
144
142
  if not self.required:
@@ -150,7 +148,6 @@ class UnionProperty(PropertyProtocol):
150
148
  no_optional: bool = False,
151
149
  json: bool = False,
152
150
  *,
153
- multipart: bool = False,
154
151
  quoted: bool = False,
155
152
  ) -> str:
156
153
  """
@@ -158,7 +155,7 @@ class UnionProperty(PropertyProtocol):
158
155
  This implementation differs slightly from `Property.get_type_string` in order to collapse
159
156
  nested union types.
160
157
  """
161
- type_strings_in_union = self.get_type_strings_in_union(no_optional=no_optional, json=json, multipart=multipart)
158
+ type_strings_in_union = self.get_type_strings_in_union(no_optional=no_optional, json=json)
162
159
  return self._get_type_string_from_inner_type_strings(type_strings_in_union)
163
160
 
164
161
  def get_imports(self, *, prefix: str) -> set[str]:
@@ -183,7 +180,7 @@ class UnionProperty(PropertyProtocol):
183
180
 
184
181
  def validate_location(self, location: oai.ParameterLocation) -> ParseError | None:
185
182
  """Returns an error if this type of property is not allowed in the given location"""
186
- from ..properties import Property
183
+ from ..properties import Property # noqa: PLC0415
187
184
 
188
185
  for inner_prop in self.inner_properties:
189
186
  if evolve(cast(Property, inner_prop), required=self.required).validate_location(location) is not None:
@@ -58,33 +58,33 @@ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
58
58
  {% endif %}
59
59
  {% endmacro %}
60
60
 
61
- {% macro body_to_kwarg(body, destination) %}
61
+ {% macro body_to_kwarg(body) %}
62
62
  {% if body.body_type == "data" %}
63
- {{ destination }} = body.to_dict()
63
+ _kwargs["data"] = body.to_dict()
64
64
  {% elif body.body_type == "files"%}
65
- {{ multipart_body(body, destination) }}
65
+ {{ multipart_body(body) }}
66
66
  {% elif body.body_type == "json" %}
67
- {{ json_body(body, destination) }}
67
+ {{ json_body(body) }}
68
68
  {% elif body.body_type == "content" %}
69
- {{ destination }} = body.payload
69
+ _kwargs["content"] = body.payload
70
70
  {% endif %}
71
71
  {% endmacro %}
72
72
 
73
- {% macro json_body(body, destination) %}
73
+ {% macro json_body(body) %}
74
74
  {% set property = body.prop %}
75
75
  {% import "property_templates/" + property.template as prop_template %}
76
76
  {% if prop_template.transform %}
77
- {{ prop_template.transform(property, property.python_name, destination) }}
77
+ {{ prop_template.transform(property, property.python_name, "_kwargs[\"json\"]") }}
78
78
  {% else %}
79
- {{ destination }} = {{ property.python_name }}
79
+ _kwargs["json"] = {{ property.python_name }}
80
80
  {% endif %}
81
81
  {% endmacro %}
82
82
 
83
- {% macro multipart_body(body, destination) %}
83
+ {% macro multipart_body(body) %}
84
84
  {% set property = body.prop %}
85
85
  {% import "property_templates/" + property.template as prop_template %}
86
86
  {% if prop_template.transform_multipart_body %}
87
- {{ prop_template.transform_multipart_body(property, property.python_name, destination) }}
87
+ {{ prop_template.transform_multipart_body(property) }}
88
88
  {% endif %}
89
89
  {% endmacro %}
90
90
 
@@ -48,15 +48,12 @@ def _get_kwargs(
48
48
  {% if endpoint.bodies | length > 1 %}
49
49
  {% for body in endpoint.bodies %}
50
50
  if isinstance(body, {{body.prop.get_type_string() }}):
51
- {% set destination = "_" + body.body_type + "_body" %}
52
- {{ body_to_kwarg(body, destination) | indent(8) }}
53
- _kwargs["{{ body.body_type.value }}"] = {{ destination }}
51
+ {{ body_to_kwarg(body) | indent(8) }}
54
52
  headers["Content-Type"] = "{{ body.content_type }}"
55
53
  {% endfor %}
56
54
  {% elif endpoint.bodies | length == 1 %}
57
55
  {% set body = endpoint.bodies[0] %}
58
- {{ body_to_kwarg(body, "_body") | indent(4) }}
59
- _kwargs["{{ body.body_type.value }}"] = _body
56
+ {{ body_to_kwarg(body) | indent(4) }}
60
57
  {% if body.content_type != "multipart/form-data" %}{# Need httpx to set the boundary automatically #}
61
58
  headers["Content-Type"] = "{{ body.content_type }}"
62
59
  {% endif %}
@@ -1,10 +1,11 @@
1
1
  from collections.abc import Mapping
2
- from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING
2
+ from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING, Generator
3
3
 
4
4
  from attrs import define as _attrs_define
5
5
  from attrs import field as _attrs_field
6
6
  {% if model.is_multipart_body %}
7
7
  import json
8
+ from .. import types
8
9
  {% endif %}
9
10
 
10
11
  from ..types import UNSET, Unset
@@ -82,32 +83,45 @@ class {{ class_name }}:
82
83
  additional_properties: dict[str, {{ additional_property_type }}] = _attrs_field(init=False, factory=dict)
83
84
  {% endif %}
84
85
 
85
- {% macro _to_dict(multipart=False) %}
86
- {% for property in model.required_properties + model.optional_properties %}
86
+ {% macro _transform_property(property, content) %}
87
87
  {% import "property_templates/" + property.template as prop_template %}
88
- {% if multipart %}
89
- {{ prop_template.transform_multipart(property, "self." + property.python_name, property.python_name) }}
90
- {% elif prop_template.transform %}
91
- {{ prop_template.transform(property=property, source="self." + property.python_name, destination=property.python_name) }}
88
+ {%- if prop_template.transform -%}
89
+ {{ prop_template.transform(property=property, source=content, destination=property.python_name) }}
90
+ {%- else -%}
91
+ {{ property.python_name }} = {{ content }}
92
+ {%- endif -%}
93
+ {% endmacro %}
94
+
95
+ {% macro multipart(property, source, destination) %}
96
+ {% import "property_templates/" + property.template as prop_template %}
97
+ {% if not property.required %}
98
+ if not isinstance({{source}}, Unset):
99
+ {{ prop_template.multipart(property, source, destination) | indent(4) }}
92
100
  {% else %}
93
- {{ property.python_name }} = self.{{ property.python_name }}
101
+ {{ prop_template.multipart(property, source, destination) }}
94
102
  {% endif %}
103
+ {% endmacro %}
95
104
 
96
- {% endfor %}
97
-
105
+ {% macro _prepare_field_dict() %}
98
106
  field_dict: dict[str, Any] = {}
99
107
  {% if model.additional_properties %}
100
108
  {% import "property_templates/" + model.additional_properties.template as prop_template %}
101
- {% if multipart %}
102
- for prop_name, prop in self.additional_properties.items():
103
- {{ prop_template.transform_multipart(model.additional_properties, "prop", "field_dict[prop_name]") | indent(4) }}
104
- {% elif prop_template.transform %}
109
+ {% if prop_template.transform %}
105
110
  for prop_name, prop in self.additional_properties.items():
106
111
  {{ prop_template.transform(model.additional_properties, "prop", "field_dict[prop_name]", declare_type=false) | indent(4) }}
107
112
  {% else %}
108
113
  field_dict.update(self.additional_properties)
109
- {% endif %}
110
- {% endif %}
114
+ {%- endif -%}
115
+ {%- endif -%}
116
+ {% endmacro %}
117
+
118
+ {% macro _to_dict() %}
119
+ {% for property in model.required_properties + model.optional_properties -%}
120
+ {{ _transform_property(property, "self." + property.python_name) }}
121
+
122
+ {% endfor %}
123
+
124
+ {{ _prepare_field_dict() }}
111
125
  {% if model.required_properties | length > 0 or model.optional_properties | length > 0 %}
112
126
  field_dict.update({
113
127
  {% for property in model.required_properties + model.optional_properties %}
@@ -134,8 +148,22 @@ return field_dict
134
148
  {{ _to_dict() | indent(8) }}
135
149
 
136
150
  {% if model.is_multipart_body %}
137
- def to_multipart(self) -> dict[str, Any]:
138
- {{ _to_dict(multipart=True) | indent(8) }}
151
+ def to_multipart(self) -> types.RequestFiles:
152
+ files: types.RequestFiles = []
153
+
154
+ {% for property in model.required_properties + model.optional_properties %}
155
+ {% set destination = "\"" + property.name + "\"" %}
156
+ {{ multipart(property, "self." + property.python_name, destination) | indent(8) }}
157
+
158
+ {% endfor %}
159
+
160
+ {% if model.additional_properties %}
161
+ for prop_name, prop in self.additional_properties.items():
162
+ {{ multipart(model.additional_properties, "prop", "prop_name") | indent(4) }}
163
+ {% endif %}
164
+
165
+ return files
166
+
139
167
  {% endif %}
140
168
 
141
169
  @classmethod
@@ -0,0 +1,3 @@
1
+ {% macro multipart(property, source, name) %}
2
+ files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain")))
3
+ {% endmacro %}
@@ -0,0 +1,7 @@
1
+ {% macro transform_header(source) %}
2
+ "true" if {{ source }} else "false"
3
+ {% endmacro %}
4
+
5
+ {% macro multipart(property, source, name) %}
6
+ files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain")))
7
+ {% endmacro %}
@@ -3,3 +3,7 @@
3
3
  if {{ property.python_name }} != {{ property.value.python_code }}{% if not property.required %}and not isinstance({{ property.python_name }}, Unset){% endif %}:
4
4
  raise ValueError(f"{{ property.name }} must match const {{ property.value.python_code }}, got '{{'{' + property.python_name + '}' }}'")
5
5
  {%- endmacro %}
6
+
7
+ {% macro multipart(property, source, name) %}
8
+ files.append(({{ name }}, (None, {{ source }}, "text/plain")))
9
+ {% endmacro %}
@@ -26,14 +26,6 @@ if not isinstance({{ source }}, Unset):
26
26
  {%- endif %}
27
27
  {% endmacro %}
28
28
 
29
- {% macro transform_multipart(property, source, destination) %}
30
- {% set transformed = source + ".isoformat().encode()" %}
31
- {% if property.required %}
32
- {{ destination }} = {{ transformed }}
33
- {%- else %}
34
- {% set type_annotation = property.get_type_string(json=True) | replace("str", "bytes") %}
35
- {{ destination }}: {{ type_annotation }} = UNSET
36
- if not isinstance({{ source }}, Unset):
37
- {{ destination }} = {{ transformed }}
38
- {%- endif %}
29
+ {% macro multipart(property, source, name) %}
30
+ files.append(({{ name }}, (None, {{ source }}.isoformat().encode(), "text/plain")))
39
31
  {% endmacro %}
@@ -26,14 +26,6 @@ if not isinstance({{ source }}, Unset):
26
26
  {%- endif %}
27
27
  {% endmacro %}
28
28
 
29
- {% macro transform_multipart(property, source, destination) %}
30
- {% set transformed = source + ".isoformat().encode()" %}
31
- {% if property.required %}
32
- {{ destination }} = {{ transformed }}
33
- {%- else %}
34
- {% set type_annotation = property.get_type_string(json=True) | replace("str", "bytes") %}
35
- {{ destination }}: {{ type_annotation }} = UNSET
36
- if not isinstance({{ source }}, Unset):
37
- {{ destination }} = {{ transformed }}
38
- {%- endif %}
29
+ {% macro multipart(property, source, name) %}
30
+ files.append(({{ name }}, (None, {{ source }}.isoformat().encode(), "text/plain")))
39
31
  {% endmacro %}
@@ -10,7 +10,7 @@
10
10
 
11
11
  {% macro check_type_for_construct(property, source) %}isinstance({{ source }}, {{ property.value_type.__name__ }}){% endmacro %}
12
12
 
13
- {% macro transform(property, source, destination, declare_type=True, multipart=False) %}
13
+ {% macro transform(property, source, destination, declare_type=True) %}
14
14
  {% set transformed = source + ".value" %}
15
15
  {% set type_string = property.get_type_string(json=True) %}
16
16
  {% if property.required %}
@@ -22,16 +22,8 @@ if not isinstance({{ source }}, Unset):
22
22
  {% endif %}
23
23
  {% endmacro %}
24
24
 
25
- {% macro transform_multipart(property, source, destination) %}
26
- {% set transformed = "(None, str(" + source + ".value" + ").encode(), \"text/plain\")" %}
27
- {% set type_string = "Union[Unset, tuple[None, bytes, str]]" %}
28
- {% if property.required %}
29
- {{ destination }} = {{ transformed }}
30
- {%- else %}
31
- {{ destination }}: {{ type_string }} = UNSET
32
- if not isinstance({{ source }}, Unset):
33
- {{ destination }} = {{ transformed }}
34
- {% endif %}
25
+ {% macro multipart(property, source, name) %}
26
+ files.append(({{ name }}, (None, str({{ source }}.value).encode(), "text/plain")))
35
27
  {% endmacro %}
36
28
 
37
29
  {% macro transform_header(source) %}
@@ -22,12 +22,6 @@ if not isinstance({{ source }}, Unset):
22
22
  {% endif %}
23
23
  {% endmacro %}
24
24
 
25
- {% macro transform_multipart(property, source, destination) %}
26
- {% if property.required %}
27
- {{ destination }} = {{ source }}.to_tuple()
28
- {% else %}
29
- {{ destination }}: {{ property.get_type_string(json=True) }} = UNSET
30
- if not isinstance({{ source }}, Unset):
31
- {{ destination }} = {{ source }}.to_tuple()
32
- {% endif %}
25
+ {% macro multipart(property, source, name) %}
26
+ files.append(({{ name }}, {{ source }}.to_tuple()))
33
27
  {% endmacro %}
@@ -0,0 +1,7 @@
1
+ {% macro transform_header(source) %}
2
+ str({{ source }})
3
+ {% endmacro %}
4
+
5
+ {% macro multipart(property, source, name) %}
6
+ files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain")))
7
+ {% endmacro %}
@@ -0,0 +1,7 @@
1
+ {% macro transform_header(source) %}
2
+ str({{ source }})
3
+ {% endmacro %}
4
+
5
+ {% macro multipart(property, source, name) %}
6
+ files.append(({{ name }}, (None, str({{source}}).encode(), "text/plain")))
7
+ {% endmacro %}
@@ -17,12 +17,8 @@ for {{ inner_source }} in (_{{ property.python_name }} or []):
17
17
  {% endif %}
18
18
  {% endmacro %}
19
19
 
20
- {% macro _transform(property, source, destination, multipart, transform_method) %}
20
+ {% macro _transform(property, source, destination, transform_method) %}
21
21
  {% set inner_property = property.inner_property %}
22
- {% if multipart %}
23
- {% set multipart_destination = destination %}
24
- {% set destination = "_temp_" + destination %}
25
- {% endif %}
26
22
  {% import "property_templates/" + inner_property.template as inner_template %}
27
23
  {% if inner_template.transform %}
28
24
  {% set inner_source = inner_property.python_name + "_data" %}
@@ -33,9 +29,6 @@ for {{ inner_source }} in {{ source }}:
33
29
  {% else %}
34
30
  {{ destination }} = {{ source }}
35
31
  {% endif %}
36
- {% if multipart %}
37
- {{ multipart_destination }} = (None, json.dumps({{ destination }}).encode(), 'application/json')
38
- {% endif %}
39
32
  {% endmacro %}
40
33
 
41
34
  {% macro check_type_for_construct(property, source) %}isinstance({{ source }}, list){% endmacro %}
@@ -44,34 +37,18 @@ for {{ inner_source }} in {{ source }}:
44
37
  {% set inner_property = property.inner_property %}
45
38
  {% set type_string = property.get_type_string(json=True) %}
46
39
  {% if property.required %}
47
- {{ _transform(property, source, destination, False, "to_dict") }}
40
+ {{ _transform(property, source, destination, "to_dict") }}
48
41
  {% else %}
49
42
  {{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = UNSET
50
43
  if not isinstance({{ source }}, Unset):
51
- {{ _transform(property, source, destination, False, "to_dict") | indent(4)}}
52
- {% endif %}
53
- {% endmacro %}
54
-
55
- {% macro transform_multipart(property, source, destination) %}
56
- {% set inner_property = property.inner_property %}
57
- {% set type_string = "Union[Unset, tuple[None, bytes, str]]" %}
58
- {% if property.required %}
59
- {{ _transform(property, source, destination, True, "to_dict") }}
60
- {% else %}
61
- {{ destination }}: {{ type_string }} = UNSET
62
- if not isinstance({{ source }}, Unset):
63
- {{ _transform(property, source, destination, True, "to_dict") | indent(4)}}
44
+ {{ _transform(property, source, destination, "to_dict") | indent(4)}}
64
45
  {% endif %}
65
46
  {% endmacro %}
66
47
 
67
- {% macro transform_multipart_body(property, source, destination) %}
48
+ {% macro multipart(property, source, destination) %}
68
49
  {% set inner_property = property.inner_property %}
69
- {% set type_string = property.get_type_string(json=True) %}
70
- {% if property.required %}
71
- {{ _transform(property, source, destination, False, "to_multipart") }}
72
- {% else %}
73
- {{ destination }}: {{ type_string }} = UNSET
74
- if not isinstance({{ source }}, Unset):
75
- {{ _transform(property, source, destination, False, "to_multipart") | indent(4)}}
76
- {% endif %}
50
+ {% import "property_templates/" + inner_property.template as inner_template %}
51
+ {% set inner_source = inner_property.python_name + "_element" %}
52
+ for {{ inner_source }} in {{ source }}:
53
+ {{ inner_template.multipart(inner_property, inner_source, destination) | indent(4) }}
77
54
  {% endmacro %}
@@ -10,7 +10,7 @@ check_{{ property.get_class_name_snake_case() }}({{ source }})
10
10
 
11
11
  {% macro check_type_for_construct(property, source) %}isinstance({{ source }}, {{ property.get_instance_type_string() }}){% endmacro %}
12
12
 
13
- {% macro transform(property, source, destination, declare_type=True, multipart=False) %}
13
+ {% macro transform(property, source, destination, declare_type=True) %}
14
14
  {% set type_string = property.get_type_string(json=True) %}
15
15
  {% if property.required %}
16
16
  {{ destination }}{% if declare_type %}: {{ type_string }}{% endif %} = {{ source }}
@@ -21,16 +21,8 @@ if not isinstance({{ source }}, Unset):
21
21
  {% endif %}
22
22
  {% endmacro %}
23
23
 
24
- {% macro transform_multipart(property, source, destination) %}
25
- {% set transformed = "(None, str(" + source + ").encode(), \"text/plain\")" %}
26
- {% set type_string = "Union[Unset, tuple[None, bytes, str]]" %}
27
- {% if property.required %}
28
- {{ destination }} = {{ transformed }}
29
- {%- else %}
30
- {{ destination }}: {{ type_string }} = UNSET
31
- if not isinstance({{ source }}, Unset):
32
- {{ destination }} = {{ transformed }}
33
- {% endif %}
24
+ {% macro multipart(property, source, name) %}
25
+ files.append(({{ name }}, (None, str({{ source }}).encode(), "text/plain")))
34
26
  {% endmacro %}
35
27
 
36
28
  {% macro transform_header(source) %}