Skip to content

Commit 60d601e

Browse files
authored
[Python] Minor fix to code format (#4172)
* test python e501 fix * 2 spaces * fix format with noqa: E501 * fix format, update samples
1 parent f763b6d commit 60d601e

File tree

15 files changed

+19
-17
lines changed

15 files changed

+19
-17
lines changed

modules/openapi-generator/src/main/resources/python/model.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class {{classname}}(object):
115115
allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501
116116
{{#isListContainer}}
117117
if (self.local_vars_configuration.client_side_validation and
118-
not set({{{name}}}).issubset(set(allowed_values))):
118+
not set({{{name}}}).issubset(set(allowed_values))): # noqa: E501
119119
raise ValueError(
120120
"Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501
121121
.format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501
@@ -124,7 +124,7 @@ class {{classname}}(object):
124124
{{/isListContainer}}
125125
{{#isMapContainer}}
126126
if (self.local_vars_configuration.client_side_validation and
127-
not set({{{name}}}.keys()).issubset(set(allowed_values))):
127+
not set({{{name}}}.keys()).issubset(set(allowed_values))): # noqa: E501
128128
raise ValueError(
129129
"Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501
130130
.format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501

samples/client/petstore/python-asyncio/petstore_api/models/enum_arrays.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def array_enum(self, array_enum):
104104
"""
105105
allowed_values = ["fish", "crab"] # noqa: E501
106106
if (self.local_vars_configuration.client_side_validation and
107-
not set(array_enum).issubset(set(allowed_values))):
107+
not set(array_enum).issubset(set(allowed_values))): # noqa: E501
108108
raise ValueError(
109109
"Invalid values for `array_enum` [{0}], must be a subset of [{1}]" # noqa: E501
110110
.format(", ".join(map(str, set(array_enum) - set(allowed_values))), # noqa: E501

samples/client/petstore/python-asyncio/petstore_api/models/map_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def map_of_enum_string(self, map_of_enum_string):
108108
"""
109109
allowed_values = ["UPPER", "lower"] # noqa: E501
110110
if (self.local_vars_configuration.client_side_validation and
111-
not set(map_of_enum_string.keys()).issubset(set(allowed_values))):
111+
not set(map_of_enum_string.keys()).issubset(set(allowed_values))): # noqa: E501
112112
raise ValueError(
113113
"Invalid keys in `map_of_enum_string` [{0}], must be a subset of [{1}]" # noqa: E501
114114
.format(", ".join(map(str, set(map_of_enum_string.keys()) - set(allowed_values))), # noqa: E501
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.3-SNAPSHOT
1+
4.2.0-SNAPSHOT

samples/client/petstore/python-experimental/docs/HasOnlyReadOnly.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**bar** | **str** | | [optional]
7-
**foo** | **str** | | [optional]
6+
**bar** | **str** | | [optional] [readonly]
7+
**foo** | **str** | | [optional] [readonly]
88

99
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1010

samples/client/petstore/python-experimental/docs/Name.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**name** | **int** | |
7-
**snake_case** | **int** | | [optional]
7+
**snake_case** | **int** | | [optional] [readonly]
88
**_property** | **str** | | [optional]
9-
**_123_number** | **int** | | [optional]
9+
**_123_number** | **int** | | [optional] [readonly]
1010

1111
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1212

samples/client/petstore/python-experimental/docs/ReadOnlyFirst.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**bar** | **str** | | [optional]
6+
**bar** | **str** | | [optional] [readonly]
77
**baz** | **str** | | [optional]
88

99
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

samples/client/petstore/python-experimental/petstore_api/configuration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ def __init__(self, host="http://petstore.swagger.io:80/v2",
138138
self.retries = None
139139
"""Adding retries to override urllib3 default value 3
140140
"""
141+
# Disable client side validation
142+
self.client_side_validation = True
141143

142144
@property
143145
def logger_file(self):

samples/client/petstore/python-tornado/petstore_api/models/enum_arrays.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def array_enum(self, array_enum):
104104
"""
105105
allowed_values = ["fish", "crab"] # noqa: E501
106106
if (self.local_vars_configuration.client_side_validation and
107-
not set(array_enum).issubset(set(allowed_values))):
107+
not set(array_enum).issubset(set(allowed_values))): # noqa: E501
108108
raise ValueError(
109109
"Invalid values for `array_enum` [{0}], must be a subset of [{1}]" # noqa: E501
110110
.format(", ".join(map(str, set(array_enum) - set(allowed_values))), # noqa: E501

samples/client/petstore/python-tornado/petstore_api/models/map_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def map_of_enum_string(self, map_of_enum_string):
108108
"""
109109
allowed_values = ["UPPER", "lower"] # noqa: E501
110110
if (self.local_vars_configuration.client_side_validation and
111-
not set(map_of_enum_string.keys()).issubset(set(allowed_values))):
111+
not set(map_of_enum_string.keys()).issubset(set(allowed_values))): # noqa: E501
112112
raise ValueError(
113113
"Invalid keys in `map_of_enum_string` [{0}], must be a subset of [{1}]" # noqa: E501
114114
.format(", ".join(map(str, set(map_of_enum_string.keys()) - set(allowed_values))), # noqa: E501

samples/client/petstore/python/petstore_api/models/enum_arrays.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def array_enum(self, array_enum):
104104
"""
105105
allowed_values = ["fish", "crab"] # noqa: E501
106106
if (self.local_vars_configuration.client_side_validation and
107-
not set(array_enum).issubset(set(allowed_values))):
107+
not set(array_enum).issubset(set(allowed_values))): # noqa: E501
108108
raise ValueError(
109109
"Invalid values for `array_enum` [{0}], must be a subset of [{1}]" # noqa: E501
110110
.format(", ".join(map(str, set(array_enum) - set(allowed_values))), # noqa: E501

samples/client/petstore/python/petstore_api/models/map_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def map_of_enum_string(self, map_of_enum_string):
108108
"""
109109
allowed_values = ["UPPER", "lower"] # noqa: E501
110110
if (self.local_vars_configuration.client_side_validation and
111-
not set(map_of_enum_string.keys()).issubset(set(allowed_values))):
111+
not set(map_of_enum_string.keys()).issubset(set(allowed_values))): # noqa: E501
112112
raise ValueError(
113113
"Invalid keys in `map_of_enum_string` [{0}], must be a subset of [{1}]" # noqa: E501
114114
.format(", ".join(map(str, set(map_of_enum_string.keys()) - set(allowed_values))), # noqa: E501

samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def array_enum(self, array_enum):
104104
"""
105105
allowed_values = ["fish", "crab"] # noqa: E501
106106
if (self.local_vars_configuration.client_side_validation and
107-
not set(array_enum).issubset(set(allowed_values))):
107+
not set(array_enum).issubset(set(allowed_values))): # noqa: E501
108108
raise ValueError(
109109
"Invalid values for `array_enum` [{0}], must be a subset of [{1}]" # noqa: E501
110110
.format(", ".join(map(str, set(array_enum) - set(allowed_values))), # noqa: E501

samples/openapi3/client/petstore/python/petstore_api/models/inline_object2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def enum_form_string_array(self, enum_form_string_array):
7979
"""
8080
allowed_values = [">", "$"] # noqa: E501
8181
if (self.local_vars_configuration.client_side_validation and
82-
not set(enum_form_string_array).issubset(set(allowed_values))):
82+
not set(enum_form_string_array).issubset(set(allowed_values))): # noqa: E501
8383
raise ValueError(
8484
"Invalid values for `enum_form_string_array` [{0}], must be a subset of [{1}]" # noqa: E501
8585
.format(", ".join(map(str, set(enum_form_string_array) - set(allowed_values))), # noqa: E501

samples/openapi3/client/petstore/python/petstore_api/models/map_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def map_of_enum_string(self, map_of_enum_string):
108108
"""
109109
allowed_values = ["UPPER", "lower"] # noqa: E501
110110
if (self.local_vars_configuration.client_side_validation and
111-
not set(map_of_enum_string.keys()).issubset(set(allowed_values))):
111+
not set(map_of_enum_string.keys()).issubset(set(allowed_values))): # noqa: E501
112112
raise ValueError(
113113
"Invalid keys in `map_of_enum_string` [{0}], must be a subset of [{1}]" # noqa: E501
114114
.format(", ".join(map(str, set(map_of_enum_string.keys()) - set(allowed_values))), # noqa: E501

0 commit comments

Comments
 (0)