Skip to content

fix: Remove spurious field_dict.update({}) for types without properties #969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def to_dict(self) -> Dict[str, Any]:
componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item
)

field_dict.update({})

return field_dict

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def to_dict(self) -> Dict[str, Any]:
componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item
)

field_dict.update({})

return field_dict

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ def to_dict(self) -> Dict[str, Any]:
componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item
)

field_dict.update({})

return field_dict

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class FreeFormModel:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Import:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ModelName:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ModelReferenceWithPeriods:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = prop.value
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def to_dict(self) -> Dict[str, Any]:

else:
field_dict[prop_name] = prop
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ModelWithAnyJsonPropertiesAdditionalPropertyType0:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class ModelWithBackslashInDescription:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = prop.to_dict()
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = prop.to_dict()
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = prop.isoformat()
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = prop.to_dict()
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class None_:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class PostResponsesUnionsSimpleBeforeComplexResponse200AType1:
def to_dict(self) -> Dict[str, Any]:
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})

return field_dict

Expand Down
2 changes: 2 additions & 0 deletions openapi_python_client/templates/model.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ field_dict.update({
field_dict.update(self.additional_properties)
{% endif %}
{% endif %}
{% if model.required_properties | length > 0 or model.optional_properties | length > 0 %}
field_dict.update({
{% for property in model.required_properties + model.optional_properties %}
{% if property.required %}
"{{ property.name }}": {{ property.python_name }},
{% endif %}
{% endfor %}
})
{% endif %}
{% for property in model.optional_properties %}
{% if not property.required %}
if {{ property.python_name }} is not UNSET:
Expand Down