Skip to content

Commit 6f9200e

Browse files
authored
Merge pull request #180 from p1c2u/fix/flake-check-fixes
Flake8 check fixes
2 parents 4b712cb + 7360fca commit 6f9200e

File tree

15 files changed

+65
-39
lines changed

15 files changed

+65
-39
lines changed

openapi_core/contrib/flask/responses.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""OpenAPI core contrib flask responses module"""
2-
import re
3-
42
from openapi_core.validation.response.datatypes import OpenAPIResponse
53

64

openapi_core/schema/content/exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ class MimeTypeNotFound(OpenAPIContentError):
1313
availableMimetypes = attr.ib()
1414

1515
def __str__(self):
16-
return "Mimetype not found: {0}. Valid mimetypes: {1}".format(self.mimetype, self.availableMimetypes)
16+
return "Mimetype not found: {0}. Valid mimetypes: {1}".format(
17+
self.mimetype, self.availableMimetypes)

openapi_core/schema/media_types/exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ class InvalidContentType(OpenAPIMediaTypeError):
2020
mimetype = attr.ib()
2121

2222
def __str__(self):
23-
return "Content for following mimetype not found: {0}".format(self.mimetype)
23+
return "Content for following mimetype not found: {0}".format(
24+
self.mimetype)

openapi_core/schema/media_types/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def unmarshal(self, value, custom_formatters=None, resolver=None):
5858
raise InvalidMediaTypeValue(exc)
5959

6060
try:
61-
return self.schema.unmarshal(value, custom_formatters=custom_formatters)
61+
return self.schema.unmarshal(
62+
value, custom_formatters=custom_formatters)
6263
except UnmarshalError as exc:
6364
raise InvalidMediaTypeValue(exc)

openapi_core/schema/parameters/exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class MissingParameter(MissingParameterError):
1717
name = attr.ib()
1818

1919
def __str__(self):
20-
return "Missing parameter (without default value): {0}".format(self.name)
20+
return "Missing parameter (without default value): {0}".format(
21+
self.name)
2122

2223

2324
@attr.s(hash=True)
@@ -42,4 +43,5 @@ class InvalidParameterValue(OpenAPIParameterError):
4243
original_exception = attr.ib()
4344

4445
def __str__(self):
45-
return "Invalid parameter value for `{0}`: {1}".format(self.name, self.original_exception)
46+
return "Invalid parameter value for `{0}`: {1}".format(
47+
self.name, self.original_exception)

openapi_core/schema/responses/exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class InvalidResponse(OpenAPIResponseError):
1313
responses = attr.ib()
1414

1515
def __str__(self):
16-
return "Unknown response http status: {0}".format(str(self.http_status))
16+
return "Unknown response http status: {0}".format(
17+
str(self.http_status))
1718

1819

1920
@attr.s(hash=True)

openapi_core/schema/schemas/_format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ def is_datetime(instance):
8282
return False
8383
if not isinstance(instance, text_type):
8484
return True
85-
85+
8686
if DATETIME_HAS_STRICT_RFC3339:
8787
return strict_rfc3339.validate_rfc3339(instance)
88-
88+
8989
if DATETIME_HAS_ISODATE:
9090
return isodate.parse_datetime(instance)
9191

openapi_core/schema/schemas/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from jsonschema._types import (
2-
TypeChecker, is_any, is_array, is_bool, is_integer,
2+
TypeChecker, is_array, is_bool, is_integer,
33
is_object, is_number,
44
)
55
from six import text_type, binary_type

openapi_core/schema/schemas/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __str__(self):
101101
class UnmarshallerStrictTypeError(UnmarshallerError):
102102
value = attr.ib()
103103
types = attr.ib()
104-
104+
105105
def __str__(self):
106106
types = ', '.join(list(map(str, self.types)))
107107
return "Value {value} is not one of types: {types}".format(

openapi_core/schema/schemas/factories.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,38 @@ class SchemaDictFactory(object):
100100
Contribution('required', dest_default=[]),
101101
Contribution('default'),
102102
Contribution('nullable', dest_default=False),
103-
Contribution('all_of', dest_prop_name='allOf', is_list=True, dest_default=[]),
104-
Contribution('one_of', dest_prop_name='oneOf', is_list=True, dest_default=[]),
105-
Contribution('additional_properties', dest_prop_name='additionalProperties', dest_default=True),
103+
Contribution(
104+
'all_of',
105+
dest_prop_name='allOf', is_list=True, dest_default=[],
106+
),
107+
Contribution(
108+
'one_of',
109+
dest_prop_name='oneOf', is_list=True, dest_default=[],
110+
),
111+
Contribution(
112+
'additional_properties',
113+
dest_prop_name='additionalProperties', dest_default=True,
114+
),
106115
Contribution('min_items', dest_prop_name='minItems'),
107116
Contribution('max_items', dest_prop_name='maxItems'),
108117
Contribution('min_length', dest_prop_name='minLength'),
109118
Contribution('max_length', dest_prop_name='maxLength'),
110119
Contribution('pattern', src_prop_attr='pattern'),
111-
Contribution('unique_items', dest_prop_name='uniqueItems', dest_default=False),
120+
Contribution(
121+
'unique_items',
122+
dest_prop_name='uniqueItems', dest_default=False,
123+
),
112124
Contribution('minimum'),
113125
Contribution('maximum'),
114126
Contribution('multiple_of', dest_prop_name='multipleOf'),
115-
Contribution('exclusive_minimum', dest_prop_name='exclusiveMinimum', dest_default=False),
116-
Contribution('exclusive_maximum', dest_prop_name='exclusiveMaximum', dest_default=False),
127+
Contribution(
128+
'exclusive_minimum',
129+
dest_prop_name='exclusiveMinimum', dest_default=False,
130+
),
131+
Contribution(
132+
'exclusive_maximum',
133+
dest_prop_name='exclusiveMaximum', dest_default=False,
134+
),
117135
Contribution('min_properties', dest_prop_name='minProperties'),
118136
Contribution('max_properties', dest_prop_name='maxProperties'),
119137
)

openapi_core/schema/schemas/models.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,20 @@
33
import functools
44
import logging
55
from collections import defaultdict
6-
from datetime import date, datetime
7-
from uuid import UUID
86
import re
97
import warnings
108

11-
from six import iteritems, integer_types, binary_type, text_type
9+
from six import iteritems
1210
from jsonschema.exceptions import ValidationError
1311

1412
from openapi_core.extensions.models.factories import ModelFactory
1513
from openapi_core.schema.schemas._format import oas30_format_checker
16-
from openapi_core.schema.schemas.enums import SchemaFormat, SchemaType
14+
from openapi_core.schema.schemas.enums import SchemaType
1715
from openapi_core.schema.schemas.exceptions import (
1816
CastError, InvalidSchemaValue,
19-
UnmarshallerError, UnmarshalValueError, UnmarshalError,
20-
)
21-
from openapi_core.schema.schemas.util import (
22-
forcebool, format_date, format_datetime, format_byte, format_uuid,
23-
format_number,
17+
UnmarshalValueError, UnmarshalError,
2418
)
19+
from openapi_core.schema.schemas.util import forcebool
2520
from openapi_core.schema.schemas.validators import OAS30Validator
2621

2722
log = logging.getLogger(__name__)
@@ -172,8 +167,9 @@ def get_unmarshal_mapping(self, custom_formatters=None, strict=True):
172167
for t, u in primitive_unmarshallers.items()
173168
)
174169

175-
pass_defaults = lambda f: functools.partial(
176-
f, custom_formatters=custom_formatters, strict=strict)
170+
def pass_defaults(f):
171+
return functools.partial(
172+
f, custom_formatters=custom_formatters, strict=strict)
177173
mapping = self.DEFAULT_UNMARSHAL_CALLABLE_GETTER.copy()
178174
mapping.update(primitive_unmarshallers_partial)
179175
mapping.update({
@@ -186,7 +182,9 @@ def get_unmarshal_mapping(self, custom_formatters=None, strict=True):
186182

187183
def get_validator(self, resolver=None):
188184
return OAS30Validator(
189-
self.__dict__, resolver=resolver, format_checker=oas30_format_checker)
185+
self.__dict__,
186+
resolver=resolver, format_checker=oas30_format_checker,
187+
)
190188

191189
def validate(self, value, resolver=None):
192190
validator = self.get_validator(resolver=resolver)
@@ -254,7 +252,8 @@ def _unmarshal_any(self, value, custom_formatters=None, strict=True):
254252
result = None
255253
for subschema in self.one_of:
256254
try:
257-
unmarshalled = subschema.unmarshal(value, custom_formatters)
255+
unmarshalled = subschema.unmarshal(
256+
value, custom_formatters)
258257
except UnmarshalError:
259258
continue
260259
else:
@@ -278,9 +277,11 @@ def _unmarshal_any(self, value, custom_formatters=None, strict=True):
278277
log.warning("failed to unmarshal any type")
279278
return value
280279

281-
def _unmarshal_collection(self, value, custom_formatters=None, strict=True):
280+
def _unmarshal_collection(
281+
self, value, custom_formatters=None, strict=True):
282282
if not isinstance(value, (list, tuple)):
283-
raise ValueError("Invalid value for collection: {0}".format(value))
283+
raise ValueError(
284+
"Invalid value for collection: {0}".format(value))
284285

285286
f = functools.partial(
286287
self.items.unmarshal,
@@ -300,7 +301,9 @@ def _unmarshal_object(self, value, model_factory=None,
300301
for one_of_schema in self.one_of:
301302
try:
302303
unmarshalled = self._unmarshal_properties(
303-
value, one_of_schema, custom_formatters=custom_formatters)
304+
value, one_of_schema,
305+
custom_formatters=custom_formatters,
306+
)
304307
except (UnmarshalError, ValueError):
305308
pass
306309
else:

openapi_core/schema/schemas/unmarshallers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from six import text_type, binary_type, integer_types
22

3-
from openapi_core.schema.schemas.enums import SchemaFormat, SchemaType
3+
from openapi_core.schema.schemas.enums import SchemaFormat
44
from openapi_core.schema.schemas.exceptions import (
55
InvalidCustomFormatSchemaValue,
66
UnmarshallerStrictTypeError,

openapi_core/schema/schemas/validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from jsonschema import _legacy_validators, _format, _types, _utils, _validators
1+
from jsonschema import _legacy_validators, _utils, _validators
22
from jsonschema.validators import create
33

44
from openapi_core.schema.schemas import _types as oas_types
@@ -56,7 +56,7 @@ class OAS30Validator(BaseOAS30Validator):
5656

5757
def iter_errors(self, instance, _schema=None):
5858
if _schema is None:
59-
_schema = self.schema
59+
_schema = self.schema
6060

6161
# append defaults to trigger validator (i.e. nullable)
6262
if 'nullable' not in _schema:

openapi_core/schema/specs/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
class Spec(object):
1515
"""Represents an OpenAPI Specification for a service."""
1616

17-
def __init__(self, info, paths, servers=None, components=None, _resolver=None):
17+
def __init__(
18+
self, info, paths, servers=None, components=None, _resolver=None):
1819
self.info = info
1920
self.paths = paths and dict(paths)
2021
self.servers = servers or []

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ django = django>=2.2; python_version>="3.0"
4848
flask = werkzeug
4949

5050
[tool:pytest]
51-
addopts = -sv --flake8 --junitxml reports/junit.xml --cov openapi_core --cov-report term-missing --cov-report xml:reports/coverage.xml tests
51+
addopts = -sv --flake8 --junitxml reports/junit.xml --cov openapi_core --cov-report term-missing --cov-report xml:reports/coverage.xml

0 commit comments

Comments
 (0)