Skip to content

Commit 9f0b5a4

Browse files
author
Doug Borg
committed
fixup: apply black formatting and remove unused import
1 parent 9450627 commit 9f0b5a4

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/openapi_python_generator/language_converters/python/service_generator.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Operation,
77
PathItem,
88
Reference,
9-
RequestBody,
109
Response,
1110
Schema,
1211
)
@@ -129,17 +128,21 @@ def generate_body_param(operation: Operation) -> Union[str, None]:
129128
return "[i.dict() for i in data]"
130129
if isinstance(items, (Schema, Schema30, Schema31)):
131130
if getattr(items, "type", None) == "object" or any(
132-
getattr(items, attr, None) for attr in ["properties", "allOf", "oneOf", "anyOf"]
131+
getattr(items, attr, None)
132+
for attr in ["properties", "allOf", "oneOf", "anyOf"]
133133
):
134134
return "[i.dict() for i in data]"
135135
return "data"
136136
# Object-like
137-
if (
138-
getattr(schema, "type", None) == "object"
139-
or any(
140-
getattr(schema, attr, None)
141-
for attr in ["properties", "allOf", "oneOf", "anyOf", "additionalProperties"]
142-
)
137+
if getattr(schema, "type", None) == "object" or any(
138+
getattr(schema, attr, None)
139+
for attr in [
140+
"properties",
141+
"allOf",
142+
"oneOf",
143+
"anyOf",
144+
"additionalProperties",
145+
]
143146
):
144147
return "data"
145148
# Primitive / unspecified
@@ -236,7 +239,9 @@ def _generate_params_from_content(content: Any):
236239
return params + default_params
237240

238241

239-
def generate_operation_id(operation: Operation, http_op: str, path_name: Optional[str] = None) -> str:
242+
def generate_operation_id(
243+
operation: Operation, http_op: str, path_name: Optional[str] = None
244+
) -> str:
240245
if operation.operationId:
241246
return common.normalize_symbol(operation.operationId)
242247
if path_name:

tests/test_service_generator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ def test_generate_services(model_data):
380380
result = generate_services(model_data.paths, library_config_dict[HTTPLibrary.httpx])
381381
for i in result:
382382
compile(i.content, "<string>", "exec")
383-
result2 = generate_services(model_data.paths, library_config_dict[HTTPLibrary.requests])
383+
result2 = generate_services(
384+
model_data.paths, library_config_dict[HTTPLibrary.requests]
385+
)
384386
for i in result2:
385387
compile(i.content, "<string>", "exec")
386388

0 commit comments

Comments
 (0)