summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepenet <6771947+epenet@users.noreply.github.com>2022-04-02 21:42:01 +0200
committerGitHub <noreply@github.com>2022-04-02 21:42:01 +0200
commite6bd67b064592ba671780e7069a279f6df89e206 (patch)
treee5c1bd14c224ed93253b3cafef8714fc7574d3bd
parent1451f0f288f5765af8d8d542d9b274ae5a5a7e28 (diff)
downloadvoluptuous-e6bd67b064592ba671780e7069a279f6df89e206.tar.gz
Enable flake8 in github actions (#459)
-rw-r--r--.github/workflows/tests.yml1
-rw-r--r--tox.ini3
-rw-r--r--voluptuous/tests/tests.py30
-rw-r--r--voluptuous/util.py4
-rw-r--r--voluptuous/validators.py10
5 files changed, 26 insertions, 22 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index fd90ddd..118b77a 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -14,6 +14,7 @@ jobs:
fail-fast: false
matrix:
include:
+ - { python-version: "3.9", session: "flake8" }
- { python-version: "3.9", session: "py39" }
- { python-version: "3.8", session: "py38" }
- { python-version: "3.7", session: "py37" }
diff --git a/tox.ini b/tox.ini
index 82ce641..ec13834 100644
--- a/tox.ini
+++ b/tox.ini
@@ -3,7 +3,8 @@ envlist = flake8,py27,py36,py37,py38,py39
[flake8]
; E501: line too long (X > 79 characters)
-ignore = E501
+; W504 line break after binary operator
+ignore = E501,W504
exclude = .tox,.venv,build,*.egg
[testenv]
diff --git a/voluptuous/tests/tests.py b/voluptuous/tests/tests.py
index 8b95500..c9d2b93 100644
--- a/voluptuous/tests/tests.py
+++ b/voluptuous/tests/tests.py
@@ -248,6 +248,7 @@ def test_email_validation_without_host():
else:
assert False, "Did not raise Invalid for empty string URL"
+
def test_email_validation_with_bad_data():
""" Test with bad data in email address """
schema = Schema({"email": Email()})
@@ -256,7 +257,7 @@ def test_email_validation_with_bad_data():
schema({"email": 'john@voluptuous.com>'})
except MultipleInvalid as e:
assert_equal(str(e),
- "expected an email address for dictionary value @ data['email']")
+ "expected an email address for dictionary value @ data['email']")
else:
assert False, "Did not raise Invalid for bad email " + email
@@ -796,7 +797,7 @@ def test_schema_empty_list():
except MultipleInvalid as e:
assert_equal(str(e), "expected a list")
else:
- assert False, "Did not raise correct Invalid"
+ assert False, "Did not raise correct Invalid"
def test_schema_empty_dict():
@@ -947,7 +948,7 @@ def test_unicode_as_key():
if sys.version_info >= (3,):
text_type = str
else:
- text_type = unicode
+ text_type = unicode # noqa: F821
schema = Schema({text_type: int})
schema({u("foobar"): 1})
@@ -1533,9 +1534,9 @@ def test_any_required_with_subschema():
def test_inclusive():
schema = Schema({
- Inclusive('x', 'stuff'): int,
- Inclusive('y', 'stuff'): int,
- })
+ Inclusive('x', 'stuff'): int,
+ Inclusive('y', 'stuff'): int,
+ })
r = schema({})
assert_equal(r, {})
@@ -1554,9 +1555,9 @@ def test_inclusive():
def test_inclusive_defaults():
schema = Schema({
- Inclusive('x', 'stuff', default=3): int,
- Inclusive('y', 'stuff', default=4): int,
- })
+ Inclusive('x', 'stuff', default=3): int,
+ Inclusive('y', 'stuff', default=4): int,
+ })
r = schema({})
assert_equal(r, {'x': 3, 'y': 4})
@@ -1572,9 +1573,9 @@ def test_inclusive_defaults():
def test_exclusive():
schema = Schema({
- Exclusive('x', 'stuff'): int,
- Exclusive('y', 'stuff'): int,
- })
+ Exclusive('x', 'stuff'): int,
+ Exclusive('y', 'stuff'): int,
+ })
r = schema({})
assert_equal(r, {})
@@ -1616,6 +1617,7 @@ def test_any_with_discriminant():
else:
assert False, "Did not raise correct Invalid"
+
if Enum:
def test_coerce_enum():
"""Test Coerce Enum"""
@@ -1641,7 +1643,7 @@ if Enum:
schema(4)
except Invalid as e:
assert_equal(str(e),
- "expected Choice or one of 1, 2, 3")
+ "expected Choice or one of 1, 2, 3")
else:
assert False, "Did not raise Invalid for String"
@@ -1649,6 +1651,6 @@ if Enum:
string_schema("hello")
except Invalid as e:
assert_equal(str(e),
- "expected StringChoice or one of 'easy', 'medium', 'hard'")
+ "expected StringChoice or one of 'easy', 'medium', 'hard'")
else:
assert False, "Did not raise Invalid for String"
diff --git a/voluptuous/util.py b/voluptuous/util.py
index e0ff43f..f57b8d7 100644
--- a/voluptuous/util.py
+++ b/voluptuous/util.py
@@ -8,7 +8,7 @@ __author__ = 'tusharmakkar08'
def _fix_str(v):
- if sys.version_info[0] == 2 and isinstance(v, unicode):
+ if sys.version_info[0] == 2 and isinstance(v, unicode): # noqa: F821
s = v
else:
s = str(v)
@@ -157,6 +157,6 @@ class Literal(object):
def u(x):
if sys.version_info < (3,):
- return unicode(x)
+ return unicode(x) # noqa: F821
else:
return x
diff --git a/voluptuous/validators.py b/voluptuous/validators.py
index bf1ab06..d0f1c43 100644
--- a/voluptuous/validators.py
+++ b/voluptuous/validators.py
@@ -452,7 +452,7 @@ def Email(v):
if not (USER_REGEX.match(user_part) and DOMAIN_REGEX.match(domain_part)):
raise EmailInvalid("Invalid email address")
return v
- except:
+ except: # noqa: E722
raise ValueError
@@ -471,7 +471,7 @@ def FqdnUrl(v):
if "." not in parsed_url.netloc:
raise UrlInvalid("must have a domain name in URL")
return v
- except:
+ except: # noqa: E722
raise ValueError
@@ -488,7 +488,7 @@ def Url(v):
try:
_url_validation(v)
return v
- except:
+ except: # noqa: E722
raise ValueError
@@ -751,7 +751,7 @@ class In(object):
except TypeError:
check = True
if check:
- raise InInvalid(self.msg or
+ raise InInvalid(self.msg or
'value must be one of {}'.format(sorted(self.container)))
return v
@@ -772,7 +772,7 @@ class NotIn(object):
except TypeError:
check = True
if check:
- raise NotInInvalid(self.msg or
+ raise NotInInvalid(self.msg or
'value must not be one of {}'.format(sorted(self.container)))
return v