Skip to content

Commit 895f13c

Browse files
committed
Merge pull request #3050 from taxpon/issue-3041
[Python] Follow PEP8 rules ( Issue #3041 )
2 parents eeb14ae + 955d39f commit 895f13c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+654
-879
lines changed

modules/swagger-codegen/src/main/resources/python/api.mustache

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class {{classname}}(object):
7373
)
7474
params[key] = val
7575
del params['kwargs']
76-
7776
{{#allParams}}
7877
{{#required}}
7978
# verify the required parameter '{{paramName}}' is set
@@ -85,28 +84,27 @@ class {{classname}}(object):
8584
{{#allParams}}
8685
{{#hasValidation}}
8786
{{#maxLength}}
88-
if '{{paramName}}' in params and len(params['{{paramName}}']) > {{maxLength}}:
87+
if '{{paramName}}' in params and len(params['{{paramName}}']) > {{maxLength}}:
8988
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`")
9089
{{/maxLength}}
9190
{{#minLength}}
92-
if '{{paramName}}' in params and len(params['{{paramName}}']) < {{minLength}}:
91+
if '{{paramName}}' in params and len(params['{{paramName}}']) < {{minLength}}:
9392
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`")
9493
{{/minLength}}
9594
{{#maximum}}
96-
if '{{paramName}}' in params and params['{{paramName}}'] > {{maximum}}:
95+
if '{{paramName}}' in params and params['{{paramName}}'] > {{maximum}}:
9796
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than or equal to `{{maximum}}`")
9897
{{/maximum}}
9998
{{#minimum}}
100-
if '{{paramName}}' in params and params['{{paramName}}'] < {{minimum}}:
99+
if '{{paramName}}' in params and params['{{paramName}}'] < {{minimum}}:
101100
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than or equal to `{{minimum}}`")
102101
{{/minimum}}
103102
{{#pattern}}
104-
if '{{paramName}}' in params and not re.search('{{vendorExtensions.x-regex}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):
103+
if '{{paramName}}' in params and not re.search('{{vendorExtensions.x-regex}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):
105104
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{pattern}}`")
106105
{{/pattern}}
107106
{{/hasValidation}}
108107
{{/allParams}}
109-
110108
resource_path = '{{path}}'.replace('{format}', 'json')
111109
path_params = {}
112110
{{#pathParams}}

modules/swagger-codegen/src/main/resources/python/api_client.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class ApiClient(object):
191191
:return: The serialized form of data.
192192
"""
193193
types = (str, int, float, bool, tuple)
194-
if sys.version_info < (3,0):
194+
if sys.version_info < (3, 0):
195195
types = types + (unicode,)
196196
if isinstance(obj, type(None)):
197197
return None

modules/swagger-codegen/src/main/resources/python/api_test.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ class {{#operations}}Test{{classname}}(unittest.TestCase):
3535
{{/operations}}
3636

3737
if __name__ == '__main__':
38-
unittest.main()
38+
unittest.main()

modules/swagger-codegen/src/main/resources/python/configuration.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import logging
1717

1818
from six import iteritems
1919

20+
2021
def singleton(cls, *args, **kw):
2122
instances = {}
2223

@@ -59,7 +60,6 @@ class Configuration(object):
5960
# access token for OAuth
6061
self.access_token = ""
6162
{{/isOAuth}}{{/authMethods}}
62-
6363
# Logging Settings
6464
self.logger = {}
6565
self.logger["package_logger"] = logging.getLogger("{{packageName}}")

modules/swagger-codegen/src/main/resources/python/model.mustache

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class {{classname}}(object):
3636
{{#vars}}
3737
self._{{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}
3838
{{/vars}}
39-
40-
{{#vars}}
39+
{{#vars}}{{#-first}}
40+
{{/-first}}
4141
@property
4242
def {{name}}(self):
4343
"""
@@ -58,7 +58,8 @@ class {{classname}}(object):
5858
:param {{name}}: The {{name}} of this {{classname}}.
5959
:type: {{datatype}}
6060
"""
61-
{{#isEnum}}allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
61+
{{#isEnum}}
62+
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
6263
if {{name}} not in allowed_values:
6364
raise ValueError(
6465
"Invalid value for `{{name}}`, must be one of {0}"
@@ -71,23 +72,23 @@ class {{classname}}(object):
7172
if not {{name}}:
7273
raise ValueError("Invalid value for `{{name}}`, must not be `None`")
7374
{{#maxLength}}
74-
if len({{name}}) > {{maxLength}}:
75+
if len({{name}}) > {{maxLength}}:
7576
raise ValueError("Invalid value for `{{name}}`, length must be less than `{{maxLength}}`")
7677
{{/maxLength}}
7778
{{#minLength}}
78-
if len({{name}}) < {{minLength}}:
79+
if len({{name}}) < {{minLength}}:
7980
raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`")
8081
{{/minLength}}
8182
{{#maximum}}
82-
if {{name}} > {{maximum}}:
83+
if {{name}} > {{maximum}}:
8384
raise ValueError("Invalid value for `{{name}}`, must be a value less than or equal to `{{maximum}}`")
8485
{{/maximum}}
8586
{{#minimum}}
86-
if {{name}} < {{minimum}}:
87+
if {{name}} < {{minimum}}:
8788
raise ValueError("Invalid value for `{{name}}`, must be a value greater than or equal to `{{minimum}}`")
8889
{{/minimum}}
8990
{{#pattern}}
90-
if not re.search('{{vendorExtensions.x-regex}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):
91+
if not re.search('{{vendorExtensions.x-regex}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):
9192
raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{pattern}}`")
9293
{{/pattern}}
9394
{{/hasValidation}}
@@ -145,6 +146,5 @@ class {{classname}}(object):
145146
Returns true if both objects are not equal
146147
"""
147148
return not self == other
148-
149149
{{/model}}
150-
{{/models}}
150+
{{/models}}

modules/swagger-codegen/src/main/resources/python/model_test.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ class Test{{classname}}(unittest.TestCase):
3434
{{/models}}
3535

3636
if __name__ == '__main__':
37-
unittest.main()
37+
unittest.main()

modules/swagger-codegen/src/main/resources/python/partial_header.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
{{#version}}OpenAPI spec version: {{{version}}}{{/version}}
1111
{{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
1212
Generated by: https://github.com/swagger-api/swagger-codegen.git
13-
13+
1414
Licensed under the Apache License, Version 2.0 (the "License");
1515
you may not use this file except in compliance with the License.
1616
You may obtain a copy of the License at
17-
17+
1818
http://www.apache.org/licenses/LICENSE-2.0
19-
19+
2020
Unless required by applicable law or agreed to in writing, software
2121
distributed under the License is distributed on an "AS IS" BASIS,
2222
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

modules/swagger-codegen/src/main/resources/python/setup.mustache

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ from setuptools import setup, find_packages
77

88
NAME = "{{packageName}}"
99
VERSION = "{{packageVersion}}"
10-
1110
{{#apiInfo}}{{#apis}}{{^hasMore}}
12-
1311
# To install the library, run the following
1412
#
1513
# python setup.py install
@@ -33,5 +31,4 @@ setup(
3331
{{appDescription}}
3432
"""
3533
)
36-
37-
{{/hasMore}}{{/apis}}{{/apiInfo}}
34+
{{/hasMore}}{{/apis}}{{/apiInfo}}

samples/client/petstore/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https://
55

66
- API version: 1.0.0
77
- Package version: 1.0.0
8-
- Build date: 2016-06-02T12:44:41.178+09:00
8+
- Build date: 2016-06-05T23:15:10.095+09:00
99
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
1010

1111
## Requirements.

samples/client/petstore/python/setup.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
OpenAPI spec version: 1.0.0
99
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
11-
11+
1212
Licensed under the Apache License, Version 2.0 (the "License");
1313
you may not use this file except in compliance with the License.
1414
You may obtain a copy of the License at
15-
15+
1616
http://www.apache.org/licenses/LICENSE-2.0
17-
17+
1818
Unless required by applicable law or agreed to in writing, software
1919
distributed under the License is distributed on an "AS IS" BASIS,
2020
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,8 +28,6 @@
2828
NAME = "swagger_client"
2929
VERSION = "1.0.0"
3030

31-
32-
3331
# To install the library, run the following
3432
#
3533
# python setup.py install
@@ -53,5 +51,3 @@
5351
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \&quot; \\
5452
"""
5553
)
56-
57-

0 commit comments

Comments
 (0)