Skip to content

Commit 7b0b93a

Browse files
dbantyEric Butler
and
Eric Butler
authored
fix: Remove spurious field_dict.update({}) for types without properties (#969)
Co-authored-by: Eric Butler <[email protected]> Co-authored-by: Dylan Anthony <[email protected]>
1 parent 7eb4093 commit 7b0b93a

18 files changed

+2
-20
lines changed

end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ def to_dict(self) -> Dict[str, Any]:
3232
componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_b_item
3333
)
3434

35-
field_dict.update({})
36-
3735
return field_dict
3836

3937
@classmethod

end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ def to_dict(self) -> Dict[str, Any]:
3232
componentsschemas_an_array_with_a_circular_ref_in_items_object_additional_properties_a_item
3333
)
3434

35-
field_dict.update({})
36-
3735
return field_dict
3836

3937
@classmethod

end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ def to_dict(self) -> Dict[str, Any]:
2424
componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item
2525
)
2626

27-
field_dict.update({})
28-
2927
return field_dict
3028

3129
@classmethod

end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class FreeFormModel:
1515
def to_dict(self) -> Dict[str, Any]:
1616
field_dict: Dict[str, Any] = {}
1717
field_dict.update(self.additional_properties)
18-
field_dict.update({})
1918

2019
return field_dict
2120

end_to_end_tests/golden-record/my_test_api_client/models/import_.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class Import:
1515
def to_dict(self) -> Dict[str, Any]:
1616
field_dict: Dict[str, Any] = {}
1717
field_dict.update(self.additional_properties)
18-
field_dict.update({})
1918

2019
return field_dict
2120

end_to_end_tests/golden-record/my_test_api_client/models/model_name.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class ModelName:
1515
def to_dict(self) -> Dict[str, Any]:
1616
field_dict: Dict[str, Any] = {}
1717
field_dict.update(self.additional_properties)
18-
field_dict.update({})
1918

2019
return field_dict
2120

end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class ModelReferenceWithPeriods:
1515
def to_dict(self) -> Dict[str, Any]:
1616
field_dict: Dict[str, Any] = {}
1717
field_dict.update(self.additional_properties)
18-
field_dict.update({})
1918

2019
return field_dict
2120

end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def to_dict(self) -> Dict[str, Any]:
1818
field_dict: Dict[str, Any] = {}
1919
for prop_name, prop in self.additional_properties.items():
2020
field_dict[prop_name] = prop.value
21-
field_dict.update({})
2221

2322
return field_dict
2423

end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def to_dict(self) -> Dict[str, Any]:
3434

3535
else:
3636
field_dict[prop_name] = prop
37-
field_dict.update({})
3837

3938
return field_dict
4039

end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class ModelWithAnyJsonPropertiesAdditionalPropertyType0:
1515
def to_dict(self) -> Dict[str, Any]:
1616
field_dict: Dict[str, Any] = {}
1717
field_dict.update(self.additional_properties)
18-
field_dict.update({})
1918

2019
return field_dict
2120

end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class ModelWithBackslashInDescription:
1717
def to_dict(self) -> Dict[str, Any]:
1818
field_dict: Dict[str, Any] = {}
1919
field_dict.update(self.additional_properties)
20-
field_dict.update({})
2120

2221
return field_dict
2322

end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def to_dict(self) -> Dict[str, Any]:
2222
field_dict: Dict[str, Any] = {}
2323
for prop_name, prop in self.additional_properties.items():
2424
field_dict[prop_name] = prop.to_dict()
25-
field_dict.update({})
2625

2726
return field_dict
2827

end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def to_dict(self) -> Dict[str, Any]:
2222
field_dict: Dict[str, Any] = {}
2323
for prop_name, prop in self.additional_properties.items():
2424
field_dict[prop_name] = prop.to_dict()
25-
field_dict.update({})
2625

2726
return field_dict
2827

end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def to_dict(self) -> Dict[str, Any]:
1818
field_dict: Dict[str, Any] = {}
1919
for prop_name, prop in self.additional_properties.items():
2020
field_dict[prop_name] = prop.isoformat()
21-
field_dict.update({})
2221

2322
return field_dict
2423

end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def to_dict(self) -> Dict[str, Any]:
1818
field_dict: Dict[str, Any] = {}
1919
for prop_name, prop in self.additional_properties.items():
2020
field_dict[prop_name] = prop.to_dict()
21-
field_dict.update({})
2221

2322
return field_dict
2423

end_to_end_tests/golden-record/my_test_api_client/models/none.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class None_:
1515
def to_dict(self) -> Dict[str, Any]:
1616
field_dict: Dict[str, Any] = {}
1717
field_dict.update(self.additional_properties)
18-
field_dict.update({})
1918

2019
return field_dict
2120

end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class PostResponsesUnionsSimpleBeforeComplexResponse200AType1:
1515
def to_dict(self) -> Dict[str, Any]:
1616
field_dict: Dict[str, Any] = {}
1717
field_dict.update(self.additional_properties)
18-
field_dict.update({})
1918

2019
return field_dict
2120

openapi_python_client/templates/model.py.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ field_dict.update({
109109
field_dict.update(self.additional_properties)
110110
{% endif %}
111111
{% endif %}
112+
{% if model.required_properties | length > 0 or model.optional_properties | length > 0 %}
112113
field_dict.update({
113114
{% for property in model.required_properties + model.optional_properties %}
114115
{% if property.required %}
115116
"{{ property.name }}": {{ property.python_name }},
116117
{% endif %}
117118
{% endfor %}
118119
})
120+
{% endif %}
119121
{% for property in model.optional_properties %}
120122
{% if not property.required %}
121123
if {{ property.python_name }} is not UNSET:

0 commit comments

Comments
 (0)