Skip to content

Commit b312cd0

Browse files
committed
try make an happy CI
1 parent 1f51974 commit b312cd0

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

openapi_python_client/parser/properties/__init__.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,10 @@ def build_union_property(
352352
) -> Tuple[Union[UnionProperty, PropertyError], Schemas]:
353353
sub_properties: List[Property] = []
354354

355-
for i, sub_prop_data in enumerate(
356-
[
357-
data
358-
for sublists in filter(lambda x: isinstance(x, Iterable), [[], data.anyOf, data.oneOf])
359-
for data in sublists
360-
]
361-
):
355+
sub_props_data_matrix: List[Union[oai.Schema, oai.Reference]] = filter(
356+
lambda x: isinstance(x, Iterable), [[], data.anyOf, data.oneOf]
357+
)
358+
for i, sub_prop_data in enumerate([data for flattenedlist in sub_props_data_matrix for data in flattenedlist]):
362359
sub_prop, schemas = property_from_data(
363360
name=f"{name}_type{i}",
364361
required=required,
@@ -445,12 +442,12 @@ def _property_from_data(
445442
if isinstance(data, oai.Reference):
446443
return _property_from_ref(name=name, required=required, parent=None, data=data, schemas=schemas)
447444

445+
sub_props_data_matrix: List[Union[oai.Schema, oai.Reference]] = filter(
446+
lambda x: isinstance(x, Iterable), [[], data.anyOf, data.oneOf]
447+
)
448+
sub_data = [data for flattenedlist in sub_props_data_matrix for data in flattenedlist]
449+
448450
# A union of a single reference should just be passed through to that reference (don't create copy class)
449-
sub_data = [
450-
data
451-
for sublists in filter(lambda x: isinstance(x, Iterable), [[], data.allOf, data.anyOf, data.oneOf])
452-
for data in sublists
453-
]
454451
if len(sub_data) == 1 and isinstance(sub_data[0], oai.Reference):
455452
return _property_from_ref(name=name, required=required, parent=data, data=sub_data[0], schemas=schemas)
456453

openapi_python_client/parser/properties/property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Property:
2222

2323
name: str
2424
required: bool
25-
nullable: bool
25+
nullable: bool = attr.ib(converter=utils.optin_bool_to_bool_converter)
2626
_type_string: ClassVar[str] = ""
2727
_json_type_string: ClassVar[str] = "" # Type of the property after JSON serialization
2828
default: Optional[str] = attr.ib()

openapi_python_client/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import builtins
22
import re
33
from keyword import iskeyword
4-
from typing import List
4+
from typing import List, Optional
55

66
delimiters = " _-"
77

@@ -73,3 +73,13 @@ def to_valid_python_identifier(value: str) -> str:
7373
return new_value
7474

7575
return f"{FIELD_PREFIX}{new_value}"
76+
77+
78+
def optin_bool_to_bool_converter(value: Optional[bool]) -> bool:
79+
"""
80+
Given a Option[bool] return a bool
81+
None are converted to False
82+
"""
83+
if value is None:
84+
return False
85+
return value

0 commit comments

Comments
 (0)