Skip to content

Commit

Permalink
[Python] Remove unnecessary if else. (#2985)
Browse files Browse the repository at this point in the history
* Remove Unnecessary `if else`

* update samples
  • Loading branch information
wy193777 authored and wing328 committed May 24, 2019
1 parent e284d2e commit 268196e
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 730 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ class {{classname}}(object):
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
else:
(data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
return data
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501

def {{operationId}}_with_http_info(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501
"""{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ def call_123_test_special_tags(self, body, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.call_123_test_special_tags_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.call_123_test_special_tags_with_http_info(body, **kwargs) # noqa: E501
return data
return self.call_123_test_special_tags_with_http_info(body, **kwargs) # noqa: E501

def call_123_test_special_tags_with_http_info(self, body, **kwargs): # noqa: E501
"""To test special tags # noqa: E501
Expand Down
78 changes: 13 additions & 65 deletions samples/client/petstore/python-asyncio/petstore_api/api/fake_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ def create_xml_item(self, xml_item, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.create_xml_item_with_http_info(xml_item, **kwargs) # noqa: E501
else:
(data) = self.create_xml_item_with_http_info(xml_item, **kwargs) # noqa: E501
return data
return self.create_xml_item_with_http_info(xml_item, **kwargs) # noqa: E501

def create_xml_item_with_http_info(self, xml_item, **kwargs): # noqa: E501
"""creates an XmlItem # noqa: E501
Expand Down Expand Up @@ -148,11 +144,7 @@ def fake_outer_boolean_serialize(self, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.fake_outer_boolean_serialize_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.fake_outer_boolean_serialize_with_http_info(**kwargs) # noqa: E501
return data
return self.fake_outer_boolean_serialize_with_http_info(**kwargs) # noqa: E501

def fake_outer_boolean_serialize_with_http_info(self, **kwargs): # noqa: E501
"""fake_outer_boolean_serialize # noqa: E501
Expand Down Expand Up @@ -240,11 +232,7 @@ def fake_outer_composite_serialize(self, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.fake_outer_composite_serialize_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.fake_outer_composite_serialize_with_http_info(**kwargs) # noqa: E501
return data
return self.fake_outer_composite_serialize_with_http_info(**kwargs) # noqa: E501

def fake_outer_composite_serialize_with_http_info(self, **kwargs): # noqa: E501
"""fake_outer_composite_serialize # noqa: E501
Expand Down Expand Up @@ -332,11 +320,7 @@ def fake_outer_number_serialize(self, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.fake_outer_number_serialize_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.fake_outer_number_serialize_with_http_info(**kwargs) # noqa: E501
return data
return self.fake_outer_number_serialize_with_http_info(**kwargs) # noqa: E501

def fake_outer_number_serialize_with_http_info(self, **kwargs): # noqa: E501
"""fake_outer_number_serialize # noqa: E501
Expand Down Expand Up @@ -424,11 +408,7 @@ def fake_outer_string_serialize(self, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.fake_outer_string_serialize_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.fake_outer_string_serialize_with_http_info(**kwargs) # noqa: E501
return data
return self.fake_outer_string_serialize_with_http_info(**kwargs) # noqa: E501

def fake_outer_string_serialize_with_http_info(self, **kwargs): # noqa: E501
"""fake_outer_string_serialize # noqa: E501
Expand Down Expand Up @@ -516,11 +496,7 @@ def test_body_with_file_schema(self, body, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_body_with_file_schema_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.test_body_with_file_schema_with_http_info(body, **kwargs) # noqa: E501
return data
return self.test_body_with_file_schema_with_http_info(body, **kwargs) # noqa: E501

def test_body_with_file_schema_with_http_info(self, body, **kwargs): # noqa: E501
"""test_body_with_file_schema # noqa: E501
Expand Down Expand Up @@ -612,11 +588,7 @@ def test_body_with_query_params(self, query, body, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_body_with_query_params_with_http_info(query, body, **kwargs) # noqa: E501
else:
(data) = self.test_body_with_query_params_with_http_info(query, body, **kwargs) # noqa: E501
return data
return self.test_body_with_query_params_with_http_info(query, body, **kwargs) # noqa: E501

def test_body_with_query_params_with_http_info(self, query, body, **kwargs): # noqa: E501
"""test_body_with_query_params # noqa: E501
Expand Down Expand Up @@ -714,11 +686,7 @@ def test_client_model(self, body, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_client_model_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.test_client_model_with_http_info(body, **kwargs) # noqa: E501
return data
return self.test_client_model_with_http_info(body, **kwargs) # noqa: E501

def test_client_model_with_http_info(self, body, **kwargs): # noqa: E501
"""To test \"client\" model # noqa: E501
Expand Down Expand Up @@ -827,11 +795,7 @@ def test_endpoint_parameters(self, number, double, pattern_without_delimiter, by
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, **kwargs) # noqa: E501
else:
(data) = self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, **kwargs) # noqa: E501
return data
return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, **kwargs) # noqa: E501

def test_endpoint_parameters_with_http_info(self, number, double, pattern_without_delimiter, byte, **kwargs): # noqa: E501
"""Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
Expand Down Expand Up @@ -1009,11 +973,7 @@ def test_enum_parameters(self, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_enum_parameters_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.test_enum_parameters_with_http_info(**kwargs) # noqa: E501
return data
return self.test_enum_parameters_with_http_info(**kwargs) # noqa: E501

def test_enum_parameters_with_http_info(self, **kwargs): # noqa: E501
"""To test enum parameters # noqa: E501
Expand Down Expand Up @@ -1130,11 +1090,7 @@ def test_group_parameters(self, required_string_group, required_boolean_group, r
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, **kwargs) # noqa: E501
else:
(data) = self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, **kwargs) # noqa: E501
return data
return self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, **kwargs) # noqa: E501

def test_group_parameters_with_http_info(self, required_string_group, required_boolean_group, required_int64_group, **kwargs): # noqa: E501
"""Fake endpoint to test group parameters (optional) # noqa: E501
Expand Down Expand Up @@ -1244,11 +1200,7 @@ def test_inline_additional_properties(self, param, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_inline_additional_properties_with_http_info(param, **kwargs) # noqa: E501
else:
(data) = self.test_inline_additional_properties_with_http_info(param, **kwargs) # noqa: E501
return data
return self.test_inline_additional_properties_with_http_info(param, **kwargs) # noqa: E501

def test_inline_additional_properties_with_http_info(self, param, **kwargs): # noqa: E501
"""test inline additionalProperties # noqa: E501
Expand Down Expand Up @@ -1339,11 +1291,7 @@ def test_json_form_data(self, param, param2, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501
else:
(data) = self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501
return data
return self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501

def test_json_form_data_with_http_info(self, param, param2, **kwargs): # noqa: E501
"""test json serialization of form data # noqa: E501
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ def test_classname(self, body, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.test_classname_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.test_classname_with_http_info(body, **kwargs) # noqa: E501
return data
return self.test_classname_with_http_info(body, **kwargs) # noqa: E501

def test_classname_with_http_info(self, body, **kwargs): # noqa: E501
"""To test class name in snake case # noqa: E501
Expand Down
54 changes: 9 additions & 45 deletions samples/client/petstore/python-asyncio/petstore_api/api/pet_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ def add_pet(self, body, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.add_pet_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.add_pet_with_http_info(body, **kwargs) # noqa: E501
return data
return self.add_pet_with_http_info(body, **kwargs) # noqa: E501

def add_pet_with_http_info(self, body, **kwargs): # noqa: E501
"""Add a new pet to the store # noqa: E501
Expand Down Expand Up @@ -146,11 +142,7 @@ def delete_pet(self, pet_id, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.delete_pet_with_http_info(pet_id, **kwargs) # noqa: E501
else:
(data) = self.delete_pet_with_http_info(pet_id, **kwargs) # noqa: E501
return data
return self.delete_pet_with_http_info(pet_id, **kwargs) # noqa: E501

def delete_pet_with_http_info(self, pet_id, **kwargs): # noqa: E501
"""Deletes a pet # noqa: E501
Expand Down Expand Up @@ -240,11 +232,7 @@ def find_pets_by_status(self, status, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501
else:
(data) = self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501
return data
return self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501

def find_pets_by_status_with_http_info(self, status, **kwargs): # noqa: E501
"""Finds Pets by status # noqa: E501
Expand Down Expand Up @@ -337,11 +325,7 @@ def find_pets_by_tags(self, tags, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501
else:
(data) = self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501
return data
return self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501

def find_pets_by_tags_with_http_info(self, tags, **kwargs): # noqa: E501
"""Finds Pets by tags # noqa: E501
Expand Down Expand Up @@ -434,11 +418,7 @@ def get_pet_by_id(self, pet_id, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501
else:
(data) = self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501
return data
return self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501

def get_pet_by_id_with_http_info(self, pet_id, **kwargs): # noqa: E501
"""Find pet by ID # noqa: E501
Expand Down Expand Up @@ -529,11 +509,7 @@ def update_pet(self, body, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.update_pet_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.update_pet_with_http_info(body, **kwargs) # noqa: E501
return data
return self.update_pet_with_http_info(body, **kwargs) # noqa: E501

def update_pet_with_http_info(self, body, **kwargs): # noqa: E501
"""Update an existing pet # noqa: E501
Expand Down Expand Up @@ -625,11 +601,7 @@ def update_pet_with_form(self, pet_id, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.update_pet_with_form_with_http_info(pet_id, **kwargs) # noqa: E501
else:
(data) = self.update_pet_with_form_with_http_info(pet_id, **kwargs) # noqa: E501
return data
return self.update_pet_with_form_with_http_info(pet_id, **kwargs) # noqa: E501

def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501
"""Updates a pet in the store with form data # noqa: E501
Expand Down Expand Up @@ -727,11 +699,7 @@ def upload_file(self, pet_id, **kwargs): # noqa: E501
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.upload_file_with_http_info(pet_id, **kwargs) # noqa: E501
else:
(data) = self.upload_file_with_http_info(pet_id, **kwargs) # noqa: E501
return data
return self.upload_file_with_http_info(pet_id, **kwargs) # noqa: E501

def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501
"""uploads an image # noqa: E501
Expand Down Expand Up @@ -833,11 +801,7 @@ def upload_file_with_required_file(self, pet_id, required_file, **kwargs): # no
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.upload_file_with_required_file_with_http_info(pet_id, required_file, **kwargs) # noqa: E501
else:
(data) = self.upload_file_with_required_file_with_http_info(pet_id, required_file, **kwargs) # noqa: E501
return data
return self.upload_file_with_required_file_with_http_info(pet_id, required_file, **kwargs) # noqa: E501

def upload_file_with_required_file_with_http_info(self, pet_id, required_file, **kwargs): # noqa: E501
"""uploads an image (required) # noqa: E501
Expand Down
Loading

0 comments on commit 268196e

Please sign in to comment.