Skip to content

Commit

Permalink
Convert codebase to adhere to flake8 W504 (PEP 8) (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacegaier authored Apr 2, 2022
1 parent e6bd67b commit 402da7c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ envlist = flake8,py27,py36,py37,py38,py39

[flake8]
; E501: line too long (X > 79 characters)
; W504 line break after binary operator
ignore = E501,W504
; W503 line break before binary operator
ignore = E501,W503
exclude = .tox,.venv,build,*.egg

[testenv]
Expand Down
11 changes: 6 additions & 5 deletions voluptuous/schema_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,15 @@ def _compile_mapping(self, schema, invalid_msg=None):

# Keys that may be required
all_required_keys = set(key for key in schema
if key is not Extra and
((self.required and not isinstance(key, (Optional, Remove))) or
isinstance(key, Required)))
if key is not Extra
and ((self.required
and not isinstance(key, (Optional, Remove)))
or isinstance(key, Required)))

# Keys that may have defaults
all_default_keys = set(key for key in schema
if isinstance(key, Required) or
isinstance(key, Optional))
if isinstance(key, Required)
or isinstance(key, Optional))

_compiled_schema = {}
for skey, svalue in iteritems(schema):
Expand Down
12 changes: 6 additions & 6 deletions voluptuous/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ def test_inequality():
def test_inequality_negative():
assert_false(Schema('foo') != Schema('foo'))

assert_false(Schema(['foo', 'bar', 'baz']) !=
Schema(['foo', 'bar', 'baz']))
assert_false(Schema(['foo', 'bar', 'baz'])
!= Schema(['foo', 'bar', 'baz']))

# Ensure two Schemas w/ two equivalent dicts initialized in a different
# order are considered equal.
Expand Down Expand Up @@ -1305,8 +1305,8 @@ def test_any_error_has_path():
s({'q': 'str', 'q2': 'tata'})
except MultipleInvalid as exc:
assert (
(exc.errors[0].path == ['q'] and exc.errors[1].path == ['q2']) or
(exc.errors[1].path == ['q'] and exc.errors[0].path == ['q2'])
(exc.errors[0].path == ['q'] and exc.errors[1].path == ['q2'])
or (exc.errors[1].path == ['q'] and exc.errors[0].path == ['q2'])
)
else:
assert False, "Did not raise AnyInvalid"
Expand All @@ -1322,8 +1322,8 @@ def test_all_error_has_path():
s({'q': 'str', 'q2': 12})
except MultipleInvalid as exc:
assert (
(exc.errors[0].path == ['q'] and exc.errors[1].path == ['q2']) or
(exc.errors[1].path == ['q'] and exc.errors[0].path == ['q2'])
(exc.errors[0].path == ['q'] and exc.errors[1].path == ['q2'])
or (exc.errors[1].path == ['q'] and exc.errors[0].path == ['q2'])
)
else:
assert False, "Did not raise AllInvalid"
Expand Down
8 changes: 4 additions & 4 deletions voluptuous/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ def __call__(self, v):
except TypeError:
check = True
if check:
raise InInvalid(self.msg or
'value must be one of {}'.format(sorted(self.container)))
raise InInvalid(self.msg
or 'value must be one of {}'.format(sorted(self.container)))
return v

def __repr__(self):
Expand All @@ -772,8 +772,8 @@ def __call__(self, v):
except TypeError:
check = True
if check:
raise NotInInvalid(self.msg or
'value must not be one of {}'.format(sorted(self.container)))
raise NotInInvalid(self.msg
or 'value must not be one of {}'.format(sorted(self.container)))
return v

def __repr__(self):
Expand Down

0 comments on commit 402da7c

Please sign in to comment.