diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py index 0efd7dcb6..c0d59cfc2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py @@ -2,7 +2,6 @@ from .a_form_data import AFormData from .a_model import AModel -from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject from .a_model_with_indirect_reference_property import AModelWithIndirectReferenceProperty from .a_model_with_indirect_self_reference_property import AModelWithIndirectSelfReferenceProperty from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_reference_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_reference_property.py index 14058761d..808bb08b7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_reference_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_reference_property.py @@ -31,9 +31,11 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - an_enum_indirect_ref: Union[Unset, AnEnum] = UNSET _an_enum_indirect_ref = d.pop("an_enum_indirect_ref", UNSET) - if not isinstance(_an_enum_indirect_ref, Unset): + an_enum_indirect_ref: Union[Unset, AnEnum] + if isinstance(_an_enum_indirect_ref, Unset): + an_enum_indirect_ref = UNSET + else: an_enum_indirect_ref = AnEnum(_an_enum_indirect_ref) a_model_with_indirect_reference_property = cls( diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_self_reference_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_self_reference_property.py index 2c101f264..61bf214f6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_self_reference_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_indirect_self_reference_property.py @@ -44,9 +44,11 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() required_self_ref = d.pop("required_self_ref") - an_enum: Union[Unset, AnEnum] = UNSET _an_enum = d.pop("an_enum", UNSET) - if not isinstance(_an_enum, Unset): + an_enum: Union[Unset, AnEnum] + if isinstance(_an_enum, Unset): + an_enum = UNSET + else: an_enum = AnEnum(_an_enum) optional_self_ref = d.pop("optional_self_ref", UNSET) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py index 4b95ec80e..515ee649e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py @@ -6,7 +6,7 @@ from dateutil.parser import isoparse from ..models.an_enum import AnEnum -from ..types import File +from ..types import UNSET, File, Unset T = TypeVar("T", bound="AModelWithPropertiesReferenceThatAreNotObject") @@ -15,165 +15,199 @@ class AModelWithPropertiesReferenceThatAreNotObject: """ """ - enum_properties_ref: List[AnEnum] - str_properties_ref: List[str] - date_properties_ref: List[datetime.date] - datetime_properties_ref: List[datetime.datetime] - int_32_properties_ref: List[int] - int_64_properties_ref: List[int] - float_properties_ref: List[float] - double_properties_ref: List[float] - file_properties_ref: List[File] - bytestream_properties_ref: List[str] - enum_properties: List[AnEnum] - str_properties: List[str] - date_properties: List[datetime.date] - datetime_properties: List[datetime.datetime] - int_32_properties: List[int] - int_64_properties: List[int] - float_properties: List[float] - double_properties: List[float] - file_properties: List[File] - bytestream_properties: List[str] - enum_property_ref: AnEnum - str_property_ref: str - date_property_ref: datetime.date - datetime_property_ref: datetime.datetime - int_32_property_ref: int - int_64_property_ref: int - float_property_ref: float - double_property_ref: float - file_property_ref: File - bytestream_property_ref: str + enum_properties_ref: Union[Unset, List[AnEnum]] = UNSET + str_properties_ref: Union[Unset, List[str]] = UNSET + date_properties_ref: Union[Unset, List[datetime.date]] = UNSET + datetime_properties_ref: Union[Unset, List[datetime.datetime]] = UNSET + int_32_properties_ref: Union[Unset, List[int]] = UNSET + int_64_properties_ref: Union[Unset, List[int]] = UNSET + float_properties_ref: Union[Unset, List[float]] = UNSET + double_properties_ref: Union[Unset, List[float]] = UNSET + file_properties_ref: Union[Unset, List[File]] = UNSET + bytestream_properties_ref: Union[Unset, List[str]] = UNSET + enum_properties: Union[Unset, List[AnEnum]] = UNSET + str_properties: Union[Unset, List[str]] = UNSET + date_properties: Union[Unset, List[datetime.date]] = UNSET + datetime_properties: Union[Unset, List[datetime.datetime]] = UNSET + int_32_properties: Union[Unset, List[int]] = UNSET + int_64_properties: Union[Unset, List[int]] = UNSET + float_properties: Union[Unset, List[float]] = UNSET + double_properties: Union[Unset, List[float]] = UNSET + file_properties: Union[Unset, List[File]] = UNSET + bytestream_properties: Union[Unset, List[str]] = UNSET + enum_property_ref: Union[Unset, AnEnum] = UNSET + str_property_ref: Union[Unset, str] = UNSET + date_property_ref: Union[Unset, datetime.date] = UNSET + datetime_property_ref: Union[Unset, datetime.datetime] = UNSET + int_32_property_ref: Union[Unset, int] = UNSET + int_64_property_ref: Union[Unset, int] = UNSET + float_property_ref: Union[Unset, float] = UNSET + double_property_ref: Union[Unset, float] = UNSET + file_property_ref: Union[Unset, File] = UNSET + bytestream_property_ref: Union[Unset, str] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: - enum_properties_ref = [] - for componentsschemas_an_other_array_of_enum_item_data in self.enum_properties_ref: - componentsschemas_an_other_array_of_enum_item = componentsschemas_an_other_array_of_enum_item_data.value + enum_properties_ref: Union[Unset, List[str]] = UNSET + if not isinstance(self.enum_properties_ref, Unset): + enum_properties_ref = [] + for componentsschemas_an_other_array_of_enum_item_data in self.enum_properties_ref: + componentsschemas_an_other_array_of_enum_item = componentsschemas_an_other_array_of_enum_item_data.value - enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) + enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) str_properties_ref = self.str_properties_ref - - date_properties_ref = [] - for componentsschemas_an_other_array_of_date_item_data in self.date_properties_ref: - componentsschemas_an_other_array_of_date_item = ( - componentsschemas_an_other_array_of_date_item_data.isoformat() - ) - date_properties_ref.append(componentsschemas_an_other_array_of_date_item) - - datetime_properties_ref = [] - for componentsschemas_an_other_array_of_date_time_item_data in self.datetime_properties_ref: - componentsschemas_an_other_array_of_date_time_item = ( - componentsschemas_an_other_array_of_date_time_item_data.isoformat() - ) - - datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) - + date_properties_ref = self.date_properties_ref + datetime_properties_ref = self.datetime_properties_ref int_32_properties_ref = self.int_32_properties_ref - int_64_properties_ref = self.int_64_properties_ref - float_properties_ref = self.float_properties_ref - double_properties_ref = self.double_properties_ref - - file_properties_ref = [] - for componentsschemas_an_other_array_of_file_item_data in self.file_properties_ref: - componentsschemas_an_other_array_of_file_item = ( - componentsschemas_an_other_array_of_file_item_data.to_tuple() - ) - - file_properties_ref.append(componentsschemas_an_other_array_of_file_item) - + file_properties_ref = self.file_properties_ref bytestream_properties_ref = self.bytestream_properties_ref - - enum_properties = [] - for componentsschemas_an_array_of_enum_item_data in self.enum_properties: - componentsschemas_an_array_of_enum_item = componentsschemas_an_array_of_enum_item_data.value - - enum_properties.append(componentsschemas_an_array_of_enum_item) - - str_properties = self.str_properties - - date_properties = [] - for componentsschemas_an_array_of_date_item_data in self.date_properties: - componentsschemas_an_array_of_date_item = componentsschemas_an_array_of_date_item_data.isoformat() - date_properties.append(componentsschemas_an_array_of_date_item) - - datetime_properties = [] - for componentsschemas_an_array_of_date_time_item_data in self.datetime_properties: - componentsschemas_an_array_of_date_time_item = componentsschemas_an_array_of_date_time_item_data.isoformat() - - datetime_properties.append(componentsschemas_an_array_of_date_time_item) - - int_32_properties = self.int_32_properties - - int_64_properties = self.int_64_properties - - float_properties = self.float_properties - - double_properties = self.double_properties - - file_properties = [] - for componentsschemas_an_array_of_file_item_data in self.file_properties: - componentsschemas_an_array_of_file_item = componentsschemas_an_array_of_file_item_data.to_tuple() - - file_properties.append(componentsschemas_an_array_of_file_item) - - bytestream_properties = self.bytestream_properties - - enum_property_ref = self.enum_property_ref.value + enum_properties: Union[Unset, List[str]] = UNSET + if not isinstance(self.enum_properties, Unset): + enum_properties = [] + for componentsschemas_an_array_of_enum_item_data in self.enum_properties: + componentsschemas_an_array_of_enum_item = componentsschemas_an_array_of_enum_item_data.value + + enum_properties.append(componentsschemas_an_array_of_enum_item) + + str_properties: Union[Unset, List[str]] = UNSET + if not isinstance(self.str_properties, Unset): + str_properties = self.str_properties + + date_properties: Union[Unset, List[str]] = UNSET + if not isinstance(self.date_properties, Unset): + date_properties = [] + for componentsschemas_an_array_of_date_item_data in self.date_properties: + componentsschemas_an_array_of_date_item = componentsschemas_an_array_of_date_item_data.isoformat() + date_properties.append(componentsschemas_an_array_of_date_item) + + datetime_properties: Union[Unset, List[str]] = UNSET + if not isinstance(self.datetime_properties, Unset): + datetime_properties = [] + for componentsschemas_an_array_of_date_time_item_data in self.datetime_properties: + componentsschemas_an_array_of_date_time_item = ( + componentsschemas_an_array_of_date_time_item_data.isoformat() + ) + + datetime_properties.append(componentsschemas_an_array_of_date_time_item) + + int_32_properties: Union[Unset, List[int]] = UNSET + if not isinstance(self.int_32_properties, Unset): + int_32_properties = self.int_32_properties + + int_64_properties: Union[Unset, List[int]] = UNSET + if not isinstance(self.int_64_properties, Unset): + int_64_properties = self.int_64_properties + + float_properties: Union[Unset, List[float]] = UNSET + if not isinstance(self.float_properties, Unset): + float_properties = self.float_properties + + double_properties: Union[Unset, List[float]] = UNSET + if not isinstance(self.double_properties, Unset): + double_properties = self.double_properties + + file_properties: Union[Unset, List[Tuple[Optional[str], Union[BinaryIO, TextIO], Optional[str]]]] = UNSET + if not isinstance(self.file_properties, Unset): + file_properties = [] + for componentsschemas_an_array_of_file_item_data in self.file_properties: + componentsschemas_an_array_of_file_item = componentsschemas_an_array_of_file_item_data.to_tuple() + + file_properties.append(componentsschemas_an_array_of_file_item) + + bytestream_properties: Union[Unset, List[str]] = UNSET + if not isinstance(self.bytestream_properties, Unset): + bytestream_properties = self.bytestream_properties + + enum_property_ref: Union[Unset, str] = UNSET + if not isinstance(self.enum_property_ref, Unset): + enum_property_ref = self.enum_property_ref.value str_property_ref = self.str_property_ref - date_property_ref = self.date_property_ref.isoformat() - datetime_property_ref = self.datetime_property_ref.isoformat() + date_property_ref: Union[Unset, str] = UNSET + if not isinstance(self.date_property_ref, Unset): + date_property_ref = self.date_property_ref.isoformat() + + datetime_property_ref: Union[Unset, str] = UNSET + if not isinstance(self.datetime_property_ref, Unset): + datetime_property_ref = self.datetime_property_ref.isoformat() int_32_property_ref = self.int_32_property_ref int_64_property_ref = self.int_64_property_ref float_property_ref = self.float_property_ref double_property_ref = self.double_property_ref - file_property_ref = self.file_property_ref.to_tuple() + file_property_ref: Union[Unset, Tuple[Optional[str], Union[BinaryIO, TextIO], Optional[str]]] = UNSET + if not isinstance(self.file_property_ref, Unset): + file_property_ref = self.file_property_ref.to_tuple() bytestream_property_ref = self.bytestream_property_ref field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) - field_dict.update( - { - "enum_properties_ref": enum_properties_ref, - "str_properties_ref": str_properties_ref, - "date_properties_ref": date_properties_ref, - "datetime_properties_ref": datetime_properties_ref, - "int32_properties_ref": int_32_properties_ref, - "int64_properties_ref": int_64_properties_ref, - "float_properties_ref": float_properties_ref, - "double_properties_ref": double_properties_ref, - "file_properties_ref": file_properties_ref, - "bytestream_properties_ref": bytestream_properties_ref, - "enum_properties": enum_properties, - "str_properties": str_properties, - "date_properties": date_properties, - "datetime_properties": datetime_properties, - "int32_properties": int_32_properties, - "int64_properties": int_64_properties, - "float_properties": float_properties, - "double_properties": double_properties, - "file_properties": file_properties, - "bytestream_properties": bytestream_properties, - "enum_property_ref": enum_property_ref, - "str_property_ref": str_property_ref, - "date_property_ref": date_property_ref, - "datetime_property_ref": datetime_property_ref, - "int32_property_ref": int_32_property_ref, - "int64_property_ref": int_64_property_ref, - "float_property_ref": float_property_ref, - "double_property_ref": double_property_ref, - "file_property_ref": file_property_ref, - "bytestream_property_ref": bytestream_property_ref, - } - ) + field_dict.update({}) + if enum_properties_ref is not UNSET: + field_dict["enum_properties_ref"] = enum_properties_ref + if str_properties_ref is not UNSET: + field_dict["str_properties_ref"] = str_properties_ref + if date_properties_ref is not UNSET: + field_dict["date_properties_ref"] = date_properties_ref + if datetime_properties_ref is not UNSET: + field_dict["datetime_properties_ref"] = datetime_properties_ref + if int_32_properties_ref is not UNSET: + field_dict["int32_properties_ref"] = int_32_properties_ref + if int_64_properties_ref is not UNSET: + field_dict["int64_properties_ref"] = int_64_properties_ref + if float_properties_ref is not UNSET: + field_dict["float_properties_ref"] = float_properties_ref + if double_properties_ref is not UNSET: + field_dict["double_properties_ref"] = double_properties_ref + if file_properties_ref is not UNSET: + field_dict["file_properties_ref"] = file_properties_ref + if bytestream_properties_ref is not UNSET: + field_dict["bytestream_properties_ref"] = bytestream_properties_ref + if enum_properties is not UNSET: + field_dict["enum_properties"] = enum_properties + if str_properties is not UNSET: + field_dict["str_properties"] = str_properties + if date_properties is not UNSET: + field_dict["date_properties"] = date_properties + if datetime_properties is not UNSET: + field_dict["datetime_properties"] = datetime_properties + if int_32_properties is not UNSET: + field_dict["int32_properties"] = int_32_properties + if int_64_properties is not UNSET: + field_dict["int64_properties"] = int_64_properties + if float_properties is not UNSET: + field_dict["float_properties"] = float_properties + if double_properties is not UNSET: + field_dict["double_properties"] = double_properties + if file_properties is not UNSET: + field_dict["file_properties"] = file_properties + if bytestream_properties is not UNSET: + field_dict["bytestream_properties"] = bytestream_properties + if enum_property_ref is not UNSET: + field_dict["enum_property_ref"] = enum_property_ref + if str_property_ref is not UNSET: + field_dict["str_property_ref"] = str_property_ref + if date_property_ref is not UNSET: + field_dict["date_property_ref"] = date_property_ref + if datetime_property_ref is not UNSET: + field_dict["datetime_property_ref"] = datetime_property_ref + if int_32_property_ref is not UNSET: + field_dict["int32_property_ref"] = int_32_property_ref + if int_64_property_ref is not UNSET: + field_dict["int64_property_ref"] = int_64_property_ref + if float_property_ref is not UNSET: + field_dict["float_property_ref"] = float_property_ref + if double_property_ref is not UNSET: + field_dict["double_property_ref"] = double_property_ref + if file_property_ref is not UNSET: + field_dict["file_property_ref"] = file_property_ref + if bytestream_property_ref is not UNSET: + field_dict["bytestream_property_ref"] = bytestream_property_ref return field_dict @@ -181,112 +215,111 @@ def to_dict(self) -> Dict[str, Any]: def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() enum_properties_ref = [] - _enum_properties_ref = d.pop("enum_properties_ref") - for componentsschemas_an_other_array_of_enum_item_data in _enum_properties_ref: + _enum_properties_ref = d.pop("enum_properties_ref", UNSET) + for componentsschemas_an_other_array_of_enum_item_data in _enum_properties_ref or []: componentsschemas_an_other_array_of_enum_item = AnEnum(componentsschemas_an_other_array_of_enum_item_data) enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) - str_properties_ref = cast(List[str], d.pop("str_properties_ref")) + str_properties_ref = d.pop("str_properties_ref", UNSET) - date_properties_ref = [] - _date_properties_ref = d.pop("date_properties_ref") - for componentsschemas_an_other_array_of_date_item_data in _date_properties_ref: - componentsschemas_an_other_array_of_date_item = isoparse( - componentsschemas_an_other_array_of_date_item_data - ).date() + date_properties_ref = d.pop("date_properties_ref", UNSET) - date_properties_ref.append(componentsschemas_an_other_array_of_date_item) + datetime_properties_ref = d.pop("datetime_properties_ref", UNSET) - datetime_properties_ref = [] - _datetime_properties_ref = d.pop("datetime_properties_ref") - for componentsschemas_an_other_array_of_date_time_item_data in _datetime_properties_ref: - componentsschemas_an_other_array_of_date_time_item = isoparse( - componentsschemas_an_other_array_of_date_time_item_data - ) - - datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) - - int_32_properties_ref = cast(List[int], d.pop("int32_properties_ref")) + int_32_properties_ref = d.pop("int32_properties_ref", UNSET) - int_64_properties_ref = cast(List[int], d.pop("int64_properties_ref")) + int_64_properties_ref = d.pop("int64_properties_ref", UNSET) - float_properties_ref = cast(List[float], d.pop("float_properties_ref")) + float_properties_ref = d.pop("float_properties_ref", UNSET) - double_properties_ref = cast(List[float], d.pop("double_properties_ref")) - - file_properties_ref = [] - _file_properties_ref = d.pop("file_properties_ref") - for componentsschemas_an_other_array_of_file_item_data in _file_properties_ref: - componentsschemas_an_other_array_of_file_item = File( - payload=BytesIO(componentsschemas_an_other_array_of_file_item_data) - ) + double_properties_ref = d.pop("double_properties_ref", UNSET) - file_properties_ref.append(componentsschemas_an_other_array_of_file_item) + file_properties_ref = d.pop("file_properties_ref", UNSET) - bytestream_properties_ref = cast(List[str], d.pop("bytestream_properties_ref")) + bytestream_properties_ref = d.pop("bytestream_properties_ref", UNSET) enum_properties = [] - _enum_properties = d.pop("enum_properties") - for componentsschemas_an_array_of_enum_item_data in _enum_properties: + _enum_properties = d.pop("enum_properties", UNSET) + for componentsschemas_an_array_of_enum_item_data in _enum_properties or []: componentsschemas_an_array_of_enum_item = AnEnum(componentsschemas_an_array_of_enum_item_data) enum_properties.append(componentsschemas_an_array_of_enum_item) - str_properties = cast(List[str], d.pop("str_properties")) + str_properties = cast(List[str], d.pop("str_properties", UNSET)) date_properties = [] - _date_properties = d.pop("date_properties") - for componentsschemas_an_array_of_date_item_data in _date_properties: + _date_properties = d.pop("date_properties", UNSET) + for componentsschemas_an_array_of_date_item_data in _date_properties or []: componentsschemas_an_array_of_date_item = isoparse(componentsschemas_an_array_of_date_item_data).date() date_properties.append(componentsschemas_an_array_of_date_item) datetime_properties = [] - _datetime_properties = d.pop("datetime_properties") - for componentsschemas_an_array_of_date_time_item_data in _datetime_properties: + _datetime_properties = d.pop("datetime_properties", UNSET) + for componentsschemas_an_array_of_date_time_item_data in _datetime_properties or []: componentsschemas_an_array_of_date_time_item = isoparse(componentsschemas_an_array_of_date_time_item_data) datetime_properties.append(componentsschemas_an_array_of_date_time_item) - int_32_properties = cast(List[int], d.pop("int32_properties")) + int_32_properties = cast(List[int], d.pop("int32_properties", UNSET)) - int_64_properties = cast(List[int], d.pop("int64_properties")) + int_64_properties = cast(List[int], d.pop("int64_properties", UNSET)) - float_properties = cast(List[float], d.pop("float_properties")) + float_properties = cast(List[float], d.pop("float_properties", UNSET)) - double_properties = cast(List[float], d.pop("double_properties")) + double_properties = cast(List[float], d.pop("double_properties", UNSET)) file_properties = [] - _file_properties = d.pop("file_properties") - for componentsschemas_an_array_of_file_item_data in _file_properties: + _file_properties = d.pop("file_properties", UNSET) + for componentsschemas_an_array_of_file_item_data in _file_properties or []: componentsschemas_an_array_of_file_item = File( payload=BytesIO(componentsschemas_an_array_of_file_item_data) ) file_properties.append(componentsschemas_an_array_of_file_item) - bytestream_properties = cast(List[str], d.pop("bytestream_properties")) + bytestream_properties = cast(List[str], d.pop("bytestream_properties", UNSET)) - enum_property_ref = AnEnum(d.pop("enum_property_ref")) + _enum_property_ref = d.pop("enum_property_ref", UNSET) + enum_property_ref: Union[Unset, AnEnum] + if isinstance(_enum_property_ref, Unset): + enum_property_ref = UNSET + else: + enum_property_ref = AnEnum(_enum_property_ref) - str_property_ref = d.pop("str_property_ref") + str_property_ref = d.pop("str_property_ref", UNSET) - date_property_ref = isoparse(d.pop("date_property_ref")).date() + _date_property_ref = d.pop("date_property_ref", UNSET) + date_property_ref: Union[Unset, datetime.date] + if isinstance(_date_property_ref, Unset): + date_property_ref = UNSET + else: + date_property_ref = isoparse(_date_property_ref).date() - datetime_property_ref = isoparse(d.pop("datetime_property_ref")) + _datetime_property_ref = d.pop("datetime_property_ref", UNSET) + datetime_property_ref: Union[Unset, datetime.datetime] + if isinstance(_datetime_property_ref, Unset): + datetime_property_ref = UNSET + else: + datetime_property_ref = isoparse(_datetime_property_ref) - int_32_property_ref = d.pop("int32_property_ref") + int_32_property_ref = d.pop("int32_property_ref", UNSET) - int_64_property_ref = d.pop("int64_property_ref") + int_64_property_ref = d.pop("int64_property_ref", UNSET) - float_property_ref = d.pop("float_property_ref") + float_property_ref = d.pop("float_property_ref", UNSET) - double_property_ref = d.pop("double_property_ref") + double_property_ref = d.pop("double_property_ref", UNSET) - file_property_ref = File(payload=BytesIO(d.pop("file_property_ref"))) + _file_property_ref = d.pop("file_property_ref", UNSET) + file_property_ref: Union[Unset, File] + if isinstance(_file_property_ref, Unset): + file_property_ref = UNSET + else: + file_property_ref = File(payload=BytesIO(_file_property_ref)) - bytestream_property_ref = d.pop("bytestream_property_ref") + bytestream_property_ref = d.pop("bytestream_property_ref", UNSET) a_model_with_properties_reference_that_are_not_object = cls( enum_properties_ref=enum_properties_ref, diff --git a/openapi_python_client/parser/properties/schemas.py b/openapi_python_client/parser/properties/schemas.py index 6e369e6ab..322b15a45 100644 --- a/openapi_python_client/parser/properties/schemas.py +++ b/openapi_python_client/parser/properties/schemas.py @@ -61,12 +61,10 @@ def from_string(*, string: str, config: Config) -> "Class": class Schemas: """Structure for containing all defined, shareable, and reusable schemas (attr classes and Enums)""" - classes_by_reference: Dict[ - _ReferencePath, _Holder[Union[Property, RecursiveReferenceInterupt]] - ] = attr.ib(factory=dict) - classes_by_name: Dict[ - _ClassName, _Holder[Union[Property, RecursiveReferenceInterupt]] - ] = attr.ib(factory=dict) + classes_by_reference: Dict[_ReferencePath, _Holder[Union[Property, RecursiveReferenceInterupt]]] = attr.ib( + factory=dict + ) + classes_by_name: Dict[_ClassName, _Holder[Union[Property, RecursiveReferenceInterupt]]] = attr.ib(factory=dict) errors: List[ParseError] = attr.ib(factory=list) diff --git a/openapi_python_client/resolver/collision_resolver.py b/openapi_python_client/resolver/collision_resolver.py index 0458354f1..66cb05fa7 100644 --- a/openapi_python_client/resolver/collision_resolver.py +++ b/openapi_python_client/resolver/collision_resolver.py @@ -1,7 +1,7 @@ import hashlib import re - from typing import Any, Dict, List, Tuple + from .reference import Reference from .resolver_types import SchemaData @@ -74,7 +74,7 @@ def _get_from_ref(self, ref: Reference, attr: SchemaData) -> SchemaData: if list(cursor) == ["$ref"]: ref2 = cursor["$ref"] - ref2 = re.sub(r'(.*)_\d',r'\1',ref2) + ref2 = re.sub(r"(.*)_\d", r"\1", ref2) ref2 = Reference(ref2, self._parent) if ref2.is_remote(): attr = self._refs[ref2.abs_path] diff --git a/openapi_python_client/resolver/pointer.py b/openapi_python_client/resolver/pointer.py index 36874e294..911f36243 100644 --- a/openapi_python_client/resolver/pointer.py +++ b/openapi_python_client/resolver/pointer.py @@ -3,7 +3,7 @@ class Pointer: - """ https://tools.ietf.org/html/rfc6901 """ + """https://tools.ietf.org/html/rfc6901""" def __init__(self, pointer: str) -> None: if pointer is None or pointer != "" and not pointer.startswith("/"): diff --git a/openapi_python_client/resolver/reference.py b/openapi_python_client/resolver/reference.py index dbd5bd007..019def096 100644 --- a/openapi_python_client/resolver/reference.py +++ b/openapi_python_client/resolver/reference.py @@ -6,7 +6,7 @@ class Reference: - """ https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03 """ + """https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03""" def __init__(self, reference: str, parent: str = None): self._ref = reference @@ -40,11 +40,11 @@ def pointer(self) -> Pointer: return Pointer(frag) def is_relative(self) -> bool: - """ return True if reference path is a relative path """ + """return True if reference path is a relative path""" return not self.is_absolute() def is_absolute(self) -> bool: - """ return True is reference path is an absolute path """ + """return True is reference path is an absolute path""" return self._parsed_ref.netloc != "" @property @@ -52,17 +52,17 @@ def value(self) -> str: return self._ref def is_url(self) -> bool: - """ return True if the reference path is pointing to an external url location """ + """return True if the reference path is pointing to an external url location""" return self.is_remote() and self._parsed_ref.netloc != "" def is_remote(self) -> bool: - """ return True if the reference pointer is pointing to a remote document """ + """return True if the reference pointer is pointing to a remote document""" return not self.is_local() def is_local(self) -> bool: - """ return True if the reference pointer is pointing to the current document """ + """return True if the reference pointer is pointing to the current document""" return self._parsed_ref.path == "" def is_full_document(self) -> bool: - """ return True if the reference pointer is pointing to the whole document content """ + """return True if the reference pointer is pointing to the whole document content""" return self.pointer.parent is None diff --git a/openapi_python_client/utils.py b/openapi_python_client/utils.py index a5e05d2a1..c2f5ed047 100644 --- a/openapi_python_client/utils.py +++ b/openapi_python_client/utils.py @@ -67,7 +67,7 @@ def to_valid_python_identifier(value: str) -> str: See: https://docs.python.org/3/reference/lexical_analysis.html#identifiers """ - new_value = fix_reserved_words(fix_keywords(sanitize(value))).lstrip('_') + new_value = fix_reserved_words(fix_keywords(sanitize(value))).lstrip("_") if new_value.isidentifier(): return new_value