openapi-python-client 0.24.3__tar.gz → 0.25.0__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.0}/PKG-INFO +3 -3
  2. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/const.py +0 -1
  3. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/file.py +2 -2
  4. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/list_property.py +0 -3
  5. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/model_property.py +0 -3
  6. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/protocol.py +0 -4
  7. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/union.py +7 -10
  8. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/endpoint_macros.py.jinja +10 -10
  9. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/endpoint_module.py.jinja +2 -5
  10. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/model.py.jinja +46 -18
  11. openapi_python_client-0.25.0/openapi_python_client/templates/property_templates/any_property.py.jinja +3 -0
  12. openapi_python_client-0.25.0/openapi_python_client/templates/property_templates/boolean_property.py.jinja +7 -0
  13. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/const_property.py.jinja +4 -0
  14. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/date_property.py.jinja +2 -10
  15. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/datetime_property.py.jinja +2 -10
  16. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/enum_property.py.jinja +3 -11
  17. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/file_property.py.jinja +2 -8
  18. openapi_python_client-0.25.0/openapi_python_client/templates/property_templates/float_property.py.jinja +7 -0
  19. openapi_python_client-0.25.0/openapi_python_client/templates/property_templates/int_property.py.jinja +7 -0
  20. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/list_property.py.jinja +8 -31
  21. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja +3 -11
  22. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/model_property.py.jinja +7 -17
  23. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/union_property.py.jinja +18 -15
  24. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/uuid_property.py.jinja +2 -9
  25. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/pyproject.toml.jinja +2 -2
  26. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/setup.py.jinja +1 -1
  27. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/types.py.jinja +13 -7
  28. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/pyproject.toml +4 -4
  29. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/any_property.py.jinja +0 -7
  30. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/boolean_property.py.jinja +0 -11
  31. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/float_property.py.jinja +0 -11
  32. openapi_python_client-0.24.3/openapi_python_client/templates/property_templates/int_property.py.jinja +0 -11
  33. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/.gitignore +0 -0
  34. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/LICENSE +0 -0
  35. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/README.md +0 -0
  36. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/__init__.py +0 -0
  37. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/__main__.py +0 -0
  38. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/cli.py +0 -0
  39. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/config.py +0 -0
  40. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/__init__.py +0 -0
  41. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/bodies.py +0 -0
  42. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/errors.py +0 -0
  43. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/openapi.py +0 -0
  44. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/__init__.py +0 -0
  45. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/any.py +0 -0
  46. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/boolean.py +0 -0
  47. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/date.py +0 -0
  48. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/datetime.py +0 -0
  49. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/enum_property.py +0 -0
  50. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/float.py +0 -0
  51. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/int.py +0 -0
  52. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/literal_enum_property.py +0 -0
  53. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/merge_properties.py +0 -0
  54. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/none.py +0 -0
  55. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/property.py +0 -0
  56. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/schemas.py +0 -0
  57. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/string.py +0 -0
  58. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/properties/uuid.py +0 -0
  59. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/parser/responses.py +0 -0
  60. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/py.typed +0 -0
  61. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/3.0.3.md +0 -0
  62. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/3.1.0.md +0 -0
  63. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/__init__.py +0 -0
  64. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/data_type.py +0 -0
  65. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/LICENSE +0 -0
  66. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/README.md +0 -0
  67. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/__init__.py +0 -0
  68. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/callback.py +0 -0
  69. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/components.py +0 -0
  70. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/contact.py +0 -0
  71. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/discriminator.py +0 -0
  72. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/encoding.py +0 -0
  73. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/example.py +0 -0
  74. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py +0 -0
  75. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/header.py +0 -0
  76. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/info.py +0 -0
  77. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/license.py +0 -0
  78. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/link.py +0 -0
  79. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/media_type.py +0 -0
  80. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py +0 -0
  81. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/oauth_flows.py +0 -0
  82. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/open_api.py +0 -0
  83. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/operation.py +0 -0
  84. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/parameter.py +0 -0
  85. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/path_item.py +0 -0
  86. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/paths.py +0 -0
  87. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/reference.py +0 -0
  88. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/request_body.py +0 -0
  89. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/response.py +0 -0
  90. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/responses.py +0 -0
  91. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/schema.py +0 -0
  92. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py +0 -0
  93. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py +0 -0
  94. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/server.py +0 -0
  95. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/server_variable.py +0 -0
  96. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/tag.py +0 -0
  97. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/openapi_schema_pydantic/xml.py +0 -0
  98. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/schema/parameter_location.py +0 -0
  99. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/.gitignore.jinja +0 -0
  100. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/README.md.jinja +0 -0
  101. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/api_init.py.jinja +0 -0
  102. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/client.py.jinja +0 -0
  103. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/endpoint_init.py.jinja +0 -0
  104. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/errors.py.jinja +0 -0
  105. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/helpers.jinja +0 -0
  106. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/int_enum.py.jinja +0 -0
  107. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/literal_enum.py.jinja +0 -0
  108. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/models_init.py.jinja +0 -0
  109. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/package_init.py.jinja +0 -0
  110. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/helpers.jinja +0 -0
  111. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/property_templates/property_macros.py.jinja +0 -0
  112. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/pyproject_ruff.toml.jinja +0 -0
  113. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/openapi_python_client/templates/str_enum.py.jinja +0 -0
  114. {openapi_python_client-0.24.3 → openapi_python_client-0.25.0}/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.0
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
29
  Requires-Dist: ruff<0.12,>=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
 
@@ -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
@@ -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
 
@@ -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
 
@@ -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]:
@@ -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) %}
@@ -22,26 +22,16 @@ if not isinstance({{ source }}, Unset):
22
22
  {%- endif %}
23
23
  {% endmacro %}
24
24
 
25
- {% macro transform_multipart_body(property, source, destination) %}
26
- {% set transformed = source + ".to_multipart()" %}
27
- {% set type_string = property.get_type_string(multipart=True) %}
25
+ {% macro transform_multipart_body(property) %}
26
+ {% set transformed = property.python_name + ".to_multipart()" %}
28
27
  {% if property.required %}
29
- {{ destination }} = {{ transformed }}
28
+ _kwargs["files"] = {{ transformed }}
30
29
  {%- else %}
31
- {{ destination }}: {{ type_string }} = UNSET
32
- if not isinstance({{ source }}, Unset):
33
- {{ destination }} = {{ transformed }}
30
+ if not isinstance({{ property.python_name }}, Unset):
31
+ _kwargs["files"] = {{ transformed }}
34
32
  {%- endif %}
35
33
  {% endmacro %}
36
34
 
37
- {% macro transform_multipart(property, source, destination) %}
38
- {% set transformed = "(None, json.dumps(" + source + ".to_dict()" + ").encode(), 'application/json')" %}
39
- {% set type_string = property.get_type_string(multipart=True) %}
40
- {% if property.required %}
41
- {{ destination }} = {{ transformed }}
42
- {%- else %}
43
- {{ destination }}: {{ type_string }} = UNSET
44
- if not isinstance({{ source }}, Unset):
45
- {{ destination }} = {{ transformed }}
46
- {%- endif %}
35
+ {% macro multipart(property, source, name) %}
36
+ files.append(({{ name }}, (None, json.dumps( {{source}}.to_dict()).encode(), "application/json")))
47
37
  {% endmacro %}
@@ -1,10 +1,10 @@
1
1
  {% macro construct(property, source) %}
2
2
  def _parse_{{ property.python_name }}(data: object) -> {{ property.get_type_string() }}:
3
- {% if "None" in property.get_type_strings_in_union(json=True, multipart=False) %}
3
+ {% if "None" in property.get_type_strings_in_union(json=True) %}
4
4
  if data is None:
5
5
  return data
6
6
  {% endif %}
7
- {% if "Unset" in property.get_type_strings_in_union(json=True, multipart=False) %}
7
+ {% if "Unset" in property.get_type_strings_in_union(json=True) %}
8
8
  if isinstance(data, Unset):
9
9
  return data
10
10
  {% endif %}
@@ -41,7 +41,7 @@ def _parse_{{ property.python_name }}(data: object) -> {{ property.get_type_stri
41
41
 
42
42
  {% macro transform(property, source, destination, declare_type=True) %}
43
43
  {% set ns = namespace(contains_properties_without_transform = false, contains_modified_properties = not property.required, has_if = false) %}
44
- {% if declare_type %}{{ destination }}: {{ property.get_type_string(json=True, multipart=False) }}{% endif %}
44
+ {% if declare_type %}{{ destination }}: {{ property.get_type_string(json=True) }}{% endif %}
45
45
 
46
46
  {% if not property.required %}
47
47
  if isinstance({{ source }}, Unset):
@@ -75,25 +75,28 @@ else:
75
75
  {% endmacro %}
76
76
 
77
77
 
78
- {% macro transform_multipart(property, source, destination) %}
79
- {% set ns = namespace(has_if = false) %}
80
- {{ destination }}: {{ property.get_type_string(json=False, multipart=True) }}
81
-
82
- {% if not property.required %}
83
- if isinstance({{ source }}, Unset):
84
- {{ destination }} = UNSET
85
- {% set ns.has_if = true %}
78
+ {% macro instance_check(inner_property, source) %}
79
+ {% if inner_property.get_instance_type_string() == "None" %}
80
+ if {{ source }} is None:
81
+ {% else %}
82
+ if isinstance({{ source }}, {{ inner_property.get_instance_type_string() }}):
86
83
  {% endif %}
84
+ {% endmacro %}
85
+
86
+ {% macro multipart(property, source, destination) %}
87
+ {% set ns = namespace(has_if = false) %}
87
88
  {% for inner_property in property.inner_properties %}
88
89
  {% if not ns.has_if %}
89
- if isinstance({{ source }}, {{ inner_property.get_instance_type_string() }}):
90
+ {{ instance_check(inner_property, source) }}
90
91
  {% set ns.has_if = true %}
91
92
  {% elif not loop.last %}
92
- elif isinstance({{ source }}, {{ inner_property.get_instance_type_string() }}):
93
+
94
+ el{{ instance_check(inner_property, source) }}
93
95
  {% else %}
96
+
94
97
  else:
95
98
  {% endif %}
96
99
  {% import "property_templates/" + inner_property.template as inner_template %}
97
- {{ inner_template.transform_multipart(inner_property, source, destination) | indent(4) | trim }}
98
- {% endfor %}
100
+ {{ inner_template.multipart(inner_property, source, destination) | indent(4) | trim }}
101
+ {%- endfor -%}
99
102
  {% endmacro %}
@@ -26,13 +26,6 @@ if not isinstance({{ source }}, Unset):
26
26
  {%- endif %}
27
27
  {% endmacro %}
28
28
 
29
- {% macro transform_multipart(property, source, destination) %}
30
- {% if property.required %}
31
- {{ destination }} = str({{ source }})
32
- {%- else %}
33
- {% set type_annotation = property.get_type_string(json=True) | replace("str", "bytes") %}
34
- {{ destination }}: {{ type_annotation }} = UNSET
35
- if not isinstance({{ source }}, Unset):
36
- {{ destination }} = str({{ source }})
37
- {%- endif %}
29
+ {% macro multipart(property, source, name) %}
30
+ files.append(({{ name }}, (None, str({{ source }}), "text/plain"))
38
31
  {% endmacro %}
@@ -19,7 +19,7 @@ include = ["CHANGELOG.md", "{{ package_name }}/py.typed"]
19
19
 
20
20
  {% if pdm %}
21
21
  dependencies = [
22
- "httpx>=0.20.0,<0.29.0",
22
+ "httpx>=0.23.0,<0.29.0",
23
23
  "attrs>=22.2.0",
24
24
  "python-dateutil>=2.8.0",
25
25
  ]
@@ -31,7 +31,7 @@ distribution = true
31
31
 
32
32
  [tool.poetry.dependencies]
33
33
  python = "^3.9"
34
- httpx = ">=0.20.0,<0.29.0"
34
+ httpx = ">=0.23.0,<0.29.0"
35
35
  attrs = ">=22.2.0"
36
36
  python-dateutil = "^2.8.0"
37
37
  {% endif %}
@@ -13,6 +13,6 @@ setup(
13
13
  long_description_content_type="text/markdown",
14
14
  packages=find_packages(),
15
15
  python_requires=">=3.9, <4",
16
- install_requires=["httpx >= 0.20.0, < 0.29.0", "attrs >= 22.2.0", "python-dateutil >= 2.8.0, < 3"],
16
+ install_requires=["httpx >= 0.23.0, < 0.29.0", "attrs >= 22.2.0", "python-dateutil >= 2.8.0, < 3"],
17
17
  package_data={"{{ package_name }}": ["py.typed"]},
18
18
  )
@@ -1,8 +1,8 @@
1
1
  """ Contains some shared types for properties """
2
2
 
3
- from collections.abc import MutableMapping
3
+ from collections.abc import Mapping, MutableMapping
4
4
  from http import HTTPStatus
5
- from typing import BinaryIO, Generic, Optional, TypeVar, Literal
5
+ from typing import BinaryIO, Generic, Optional, TypeVar, Literal, Union, IO
6
6
 
7
7
  from attrs import define
8
8
 
@@ -14,9 +14,15 @@ class Unset:
14
14
 
15
15
  UNSET: Unset = Unset()
16
16
 
17
- {# Used as `FileProperty._json_type_string` #}
18
- FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]]
19
-
17
+ # The types that `httpx.Client(files=)` can accept, copied from that library.
18
+ FileContent = Union[IO[bytes], bytes, str]
19
+ FileTypes = Union[
20
+ # (filename, file (or bytes), content_type)
21
+ tuple[Optional[str], FileContent, Optional[str]],
22
+ # (filename, file (or bytes), content_type, headers)
23
+ tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
24
+ ]
25
+ RequestFiles = list[tuple[str, FileTypes]]
20
26
 
21
27
  @define
22
28
  class File:
@@ -26,7 +32,7 @@ class File:
26
32
  file_name: Optional[str] = None
27
33
  mime_type: Optional[str] = None
28
34
 
29
- def to_tuple(self) -> FileJsonType:
35
+ def to_tuple(self) -> FileTypes:
30
36
  """ Return a tuple representation that httpx will accept for multipart/form-data """
31
37
  return self.file_name, self.payload, self.mime_type
32
38
 
@@ -44,4 +50,4 @@ class Response(Generic[T]):
44
50
  parsed: Optional[T]
45
51
 
46
52
 
47
- __all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"]
53
+ __all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]
@@ -6,19 +6,19 @@ license = { text = "MIT" }
6
6
  requires-python = ">=3.9,<4.0"
7
7
  dependencies = [
8
8
  "jinja2>=3.0.0,<4.0.0",
9
- "typer>0.6,<0.16",
9
+ "typer>0.6,<0.17",
10
10
  "colorama>=0.4.3; sys_platform == \"win32\"",
11
11
  "shellingham>=1.3.2,<2.0.0",
12
12
  "pydantic>=2.10,<3.0.0",
13
13
  "attrs>=22.2.0",
14
14
  "python-dateutil>=2.8.1,<3.0.0",
15
- "httpx>=0.20.0,<0.29.0",
15
+ "httpx>=0.23.0,<0.29.0",
16
16
  "ruamel.yaml>=0.18.6,<0.19.0",
17
17
  "ruff>=0.2,<0.12",
18
18
  "typing-extensions>=4.8.0,<5.0.0",
19
19
  ]
20
20
  name = "openapi-python-client"
21
- version = "0.24.3"
21
+ version = "0.25.0"
22
22
  description = "Generate modern Python clients from OpenAPI"
23
23
  keywords = [
24
24
  "OpenAPI",
@@ -129,7 +129,7 @@ composite = ["test --cov openapi_python_client tests --cov-report=term-missing"]
129
129
 
130
130
  [tool.pdm.scripts.regen_integration]
131
131
  shell = """
132
- openapi-python-client generate --overwrite --url https://raw.githubusercontent.com/openapi-generators/openapi-test-server/main/openapi.json --config integration-tests/config.yaml --meta pdm --output-path integration-tests \
132
+ openapi-python-client generate --overwrite --url https://raw.githubusercontent.com/openapi-generators/openapi-test-server/refs/tags/v0.2.1/openapi.yaml --config integration-tests/config.yaml --meta none --output-path integration-tests/integration_tests \
133
133
  """
134
134
 
135
135
  [build-system]
@@ -1,7 +0,0 @@
1
- {% macro transform_multipart(property, source, destination) %}
2
- {% if not property.required %}
3
- {{ destination }} = {{source}} if isinstance({{source}}, Unset) else (None, str({{source}}).encode(), "text/plain")
4
- {% else %}
5
- {{ destination }} = (None, str({{ source }}).encode(), "text/plain")
6
- {% endif %}
7
- {% endmacro %}
@@ -1,11 +0,0 @@
1
- {% macro transform_header(source) %}
2
- "true" if {{ source }} else "false"
3
- {% endmacro %}
4
-
5
- {% macro transform_multipart(property, source, destination) %}
6
- {% if not property.required %}
7
- {{ destination }} = {{source}} if isinstance({{source}}, Unset) else (None, str({{source}}).encode(), "text/plain")
8
- {% else %}
9
- {{ destination }} = (None, str({{ source }}).encode(), "text/plain")
10
- {% endif %}
11
- {% endmacro %}
@@ -1,11 +0,0 @@
1
- {% macro transform_header(source) %}
2
- str({{ source }})
3
- {% endmacro %}
4
-
5
- {% macro transform_multipart(property, source, destination) %}
6
- {% if not property.required %}
7
- {{ destination }} = {{source}} if isinstance({{source}}, Unset) else (None, str({{source}}).encode(), "text/plain")
8
- {% else %}
9
- {{ destination }} = (None, str({{ source }}).encode(), "text/plain")
10
- {% endif %}
11
- {% endmacro %}
@@ -1,11 +0,0 @@
1
- {% macro transform_header(source) %}
2
- str({{ source }})
3
- {% endmacro %}
4
-
5
- {% macro transform_multipart(property, source, destination) %}
6
- {% if not property.required %}
7
- {{ destination }} = {{source}} if isinstance({{source}}, Unset) else (None, str({{source}}).encode(), "text/plain")
8
- {% else %}
9
- {{ destination }} = (None, str({{ source }}).encode(), "text/plain")
10
- {% endif %}
11
- {% endmacro %}