Skip to content

Commit 986f152

Browse files
committed
Fix: Property.is_base_type and it usage
1 parent 1577f67 commit 986f152

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

openapi_python_client/parser/properties/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ class ListProperty(Property, Generic[InnerProp]):
190190

191191
# pylint: disable=unused-argument
192192
def get_base_type_string(self, *, quoted: bool = False) -> str:
193-
return f"List[{self.inner_property.get_type_string(quoted=self.inner_property.is_base_type)}]"
193+
return f"List[{self.inner_property.get_type_string(quoted=not self.inner_property.is_base_type)}]"
194194

195195
def get_base_json_type_string(self, *, quoted: bool = False) -> str:
196-
return f"List[{self.inner_property.get_type_string(json=True, quoted=self.inner_property.is_base_type)}]"
196+
return f"List[{self.inner_property.get_type_string(json=True, quoted=not self.inner_property.is_base_type)}]"
197197

198198
def get_instance_type_string(self) -> str:
199199
"""Get a string representation of runtime type that should be used for `isinstance` checks"""
@@ -226,7 +226,7 @@ class UnionProperty(Property):
226226
template: ClassVar[str] = "union_property.py.jinja"
227227

228228
def _get_inner_type_strings(self, json: bool = False) -> Set[str]:
229-
return {p.get_type_string(no_optional=True, json=json, quoted=p.is_base_type) for p in self.inner_properties}
229+
return {p.get_type_string(no_optional=True, json=json, quoted=not p.is_base_type) for p in self.inner_properties}
230230

231231
@staticmethod
232232
def _get_type_string_from_inner_type_strings(inner_types: Set[str]) -> str:
@@ -235,7 +235,7 @@ def _get_type_string_from_inner_type_strings(inner_types: Set[str]) -> str:
235235
return f"Union[{', '.join(sorted(inner_types))}]"
236236

237237
# pylint: disable=unused-argument
238-
def get_base_type_string(self, *, quoted: bool = True) -> str:
238+
def get_base_type_string(self, *, quoted: bool = False) -> str:
239239
return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=False))
240240

241241
def get_base_json_type_string(self, *, quoted: bool = False) -> str:

openapi_python_client/parser/properties/property.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def is_base_type(self) -> bool:
172172
from . import ListProperty, ModelProperty, UnionProperty
173173

174174
return self.__class__.__name__ not in {
175-
ModelProperty.__class__.__name__,
176-
ListProperty.__class__.__name__,
177-
UnionProperty.__class__.__name__,
175+
ModelProperty.__name__,
176+
ListProperty.__name__,
177+
UnionProperty.__name__,
178178
}

openapi_python_client/templates/model.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
2525

2626

2727
{% if model.additional_properties %}
28-
{% set additional_property_type = 'Any' if model.additional_properties == True else model.additional_properties.get_type_string(model_parent=model, quoted=model.additional_properties.is_base_type) %}
28+
{% set additional_property_type = 'Any' if model.additional_properties == True else model.additional_properties.get_type_string(model_parent=model, quoted=not model.additional_properties.is_base_type) %}
2929
{% endif %}
3030

3131
{% set class_name = model.class_info.name %}

0 commit comments

Comments
 (0)