summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2021-08-04 10:29:44 +0100
committerJulian Berman <Julian@GrayVines.com>2021-08-04 10:29:44 +0100
commite908b8055596329f0b4ba1bc0dc1c793b437299f (patch)
treecb2bb0a41b6b8b8b26715e17bcdc944a676e29a1
parent39697cda809169cf7031839bb0174b5d8136029e (diff)
downloadjsonschema-draft2020-12.tar.gz
Fix missing trailing commas.draft2020-12
Add flake8-commas to ensure this stays the case.
-rw-r--r--docs/conf.py7
-rw-r--r--jsonschema/_format.py8
-rw-r--r--jsonschema/_legacy_validators.py13
-rw-r--r--jsonschema/_utils.py26
-rw-r--r--jsonschema/_validators.py36
-rw-r--r--jsonschema/cli.py2
-rw-r--r--jsonschema/exceptions.py4
-rw-r--r--jsonschema/tests/_suite.py6
-rw-r--r--jsonschema/tests/test_cli.py12
-rw-r--r--jsonschema/tests/test_exceptions.py2
-rw-r--r--jsonschema/tests/test_format.py4
-rw-r--r--jsonschema/tests/test_jsonschema_test_suite.py2
-rw-r--r--jsonschema/tests/test_validators.py73
-rw-r--r--jsonschema/validators.py6
-rw-r--r--tox.ini1
15 files changed, 92 insertions, 110 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 2b9637f..f1f0c54 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,4 +1,3 @@
-from textwrap import dedent
import os
import re
import sys
@@ -78,11 +77,9 @@ pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
-doctest_global_setup = dedent(
- """
- from jsonschema import *
+doctest_global_setup = """
+from jsonschema import *
"""
-)
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
diff --git a/jsonschema/_format.py b/jsonschema/_format.py
index 19f4283..9c351f9 100644
--- a/jsonschema/_format.py
+++ b/jsonschema/_format.py
@@ -168,15 +168,15 @@ def _checks_drafts(
if draft7:
func = _draft_checkers["draft7"].checks(draft7, raises)(func)
if draft202012:
- func = _draft_checkers["draft202012"].checks(
- draft202012, raises
- )(func)
+ func = _draft_checkers["draft202012"].checks(draft202012, raises)(
+ func,
+ )
# Oy. This is bad global state, but relied upon for now, until
# deprecation. See https://github.com/Julian/jsonschema/issues/519
# and test_format_checkers_come_with_defaults
FormatChecker.cls_checks(
- draft202012 or draft7 or draft6 or draft4 or draft3, raises
+ draft202012 or draft7 or draft6 or draft4 or draft3, raises,
)(func)
return func
return wrap
diff --git a/jsonschema/_legacy_validators.py b/jsonschema/_legacy_validators.py
index 7cb6df9..63adf49 100644
--- a/jsonschema/_legacy_validators.py
+++ b/jsonschema/_legacy_validators.py
@@ -32,9 +32,8 @@ def dependencies_draft3(validator, dependencies, instance, schema):
yield error
elif validator.is_type(dependency, "string"):
if dependency not in instance:
- yield ValidationError(
- "%r is a dependency of %r" % (dependency, property)
- )
+ message = "%r is a dependency of %r"
+ yield ValidationError(message % (dependency, property))
else:
for each in dependency:
if each not in instance:
@@ -77,7 +76,7 @@ def disallow_draft3(validator, disallow, instance, schema):
for disallowed in _utils.ensure_list(disallow):
if validator.is_valid(instance, {"type": [disallowed]}):
yield ValidationError(
- "%r is disallowed for %r" % (disallowed, instance)
+ "%r is disallowed for %r" % (disallowed, instance),
)
@@ -136,7 +135,7 @@ def minimum_draft3_draft4(validator, minimum, instance, schema):
if failed:
yield ValidationError(
- "%r is %s the minimum of %r" % (instance, cmp, minimum)
+ "%r is %s the minimum of %r" % (instance, cmp, minimum),
)
@@ -153,7 +152,7 @@ def maximum_draft3_draft4(validator, maximum, instance, schema):
if failed:
yield ValidationError(
- "%r is %s the maximum of %r" % (instance, cmp, maximum)
+ "%r is %s the maximum of %r" % (instance, cmp, maximum),
)
@@ -208,5 +207,5 @@ def contains_draft6_draft7(validator, contains, instance, schema):
if not any(validator.is_valid(element, contains) for element in instance):
yield ValidationError(
- "None of %r are valid under the given schema" % (instance,)
+ "None of %r are valid under the given schema" % (instance,),
)
diff --git a/jsonschema/_utils.py b/jsonschema/_utils.py
index 1b81a09..9b02513 100644
--- a/jsonschema/_utils.py
+++ b/jsonschema/_utils.py
@@ -280,16 +280,16 @@ def find_evaluated_item_indexes_by_schema(validator, instance, schema):
if "if" in schema:
if validator.is_valid(instance, schema["if"]):
evaluated_indexes += find_evaluated_item_indexes_by_schema(
- validator, instance, schema["if"]
+ validator, instance, schema["if"],
)
if "then" in schema:
evaluated_indexes += find_evaluated_item_indexes_by_schema(
- validator, instance, schema["then"]
+ validator, instance, schema["then"],
)
else:
if "else" in schema:
evaluated_indexes += find_evaluated_item_indexes_by_schema(
- validator, instance, schema["else"]
+ validator, instance, schema["else"],
)
for keyword in ["contains", "unevaluatedItems"]:
@@ -304,7 +304,7 @@ def find_evaluated_item_indexes_by_schema(validator, instance, schema):
errs = list(validator.descend(instance, subschema))
if not errs:
evaluated_indexes += find_evaluated_item_indexes_by_schema(
- validator, instance, subschema
+ validator, instance, subschema,
)
return evaluated_indexes
@@ -328,13 +328,13 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema):
try:
evaluated_keys += find_evaluated_property_keys_by_schema(
- validator, instance, resolved
+ validator, instance, resolved,
)
finally:
validator.resolver.pop_scope()
for keyword in [
- "properties", "additionalProperties", "unevaluatedProperties"
+ "properties", "additionalProperties", "unevaluatedProperties",
]:
if keyword in schema:
if validator.is_type(schema[keyword], "boolean"):
@@ -345,7 +345,7 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema):
if validator.is_type(schema[keyword], "object"):
for property, subschema in schema[keyword].items():
if property in instance and validator.is_valid(
- instance[property], subschema
+ instance[property], subschema,
):
evaluated_keys.append(property)
@@ -353,7 +353,7 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema):
for property, value in instance.items():
for pattern, subschema in schema["patternProperties"].items():
if re.search(pattern, property) and validator.is_valid(
- {property: value}, schema["patternProperties"]
+ {property: value}, schema["patternProperties"],
):
evaluated_keys.append(property)
@@ -362,7 +362,7 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema):
if property not in instance:
continue
evaluated_keys += find_evaluated_property_keys_by_schema(
- validator, instance, subschema
+ validator, instance, subschema,
)
for keyword in ["allOf", "oneOf", "anyOf"]:
@@ -371,22 +371,22 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema):
errs = list(validator.descend(instance, subschema))
if not errs:
evaluated_keys += find_evaluated_property_keys_by_schema(
- validator, instance, subschema
+ validator, instance, subschema,
)
if "if" in schema:
if validator.is_valid(instance, schema["if"]):
evaluated_keys += find_evaluated_property_keys_by_schema(
- validator, instance, schema["if"]
+ validator, instance, schema["if"],
)
if "then" in schema:
evaluated_keys += find_evaluated_property_keys_by_schema(
- validator, instance, schema["then"]
+ validator, instance, schema["then"],
)
else:
if "else" in schema:
evaluated_keys += find_evaluated_property_keys_by_schema(
- validator, instance, schema["else"]
+ validator, instance, schema["else"],
)
return evaluated_keys
diff --git a/jsonschema/_validators.py b/jsonschema/_validators.py
index b6a2f9c..77063fa 100644
--- a/jsonschema/_validators.py
+++ b/jsonschema/_validators.py
@@ -77,7 +77,7 @@ def items(validator, items, instance, schema):
if not items:
if len(instance) > len(schema['prefixItems']):
yield ValidationError(
- "%r has more items than defined in prefixItems" % instance
+ "%r has more items than defined in prefixItems" % instance,
)
else:
non_prefixed_items = instance[len(schema['prefixItems']):] \
@@ -104,7 +104,7 @@ def additionalItems(validator, aI, instance, schema):
error = "Additional items are not allowed (%s %s unexpected)"
yield ValidationError(
error %
- extras_msg(instance[len(schema.get("items", [])):])
+ extras_msg(instance[len(schema.get("items", [])):]),
)
@@ -134,7 +134,7 @@ def contains(validator, contains, instance, schema):
# default contains behavior
if not matches:
yield ValidationError(
- "None of %r are valid under the given schema" % (instance,)
+ "None of %r are valid under the given schema" % (instance,),
)
return
@@ -143,8 +143,8 @@ def contains(validator, contains, instance, schema):
yield ValidationError(
"Too few matches under the given schema. "
"Expected %d but there were only %d." % (
- min_contains, matches
- )
+ min_contains, matches,
+ ),
)
return
@@ -153,8 +153,8 @@ def contains(validator, contains, instance, schema):
yield ValidationError(
"Too many matches under the given schema. "
"Expected %d but there were only %d." % (
- max_contains, matches
- )
+ max_contains, matches,
+ ),
)
return
@@ -163,8 +163,8 @@ def contains(validator, contains, instance, schema):
yield ValidationError(
"Invalid number or matches under the given schema, "
"expected between %d and %d, got %d" % (
- min_contains, max_contains, matches
- )
+ min_contains, max_contains, matches,
+ ),
)
return
@@ -199,7 +199,7 @@ def minimum(validator, minimum, instance, schema):
if instance < minimum:
yield ValidationError(
- "%r is less than the minimum of %r" % (instance, minimum)
+ "%r is less than the minimum of %r" % (instance, minimum),
)
@@ -209,7 +209,7 @@ def maximum(validator, maximum, instance, schema):
if instance > maximum:
yield ValidationError(
- "%r is greater than the maximum of %r" % (instance, maximum)
+ "%r is greater than the maximum of %r" % (instance, maximum),
)
@@ -404,7 +404,7 @@ def required(validator, required, instance, schema):
def minProperties(validator, mP, instance, schema):
if validator.is_type(instance, "object") and len(instance) < mP:
yield ValidationError(
- "%r does not have enough properties" % (instance,)
+ "%r does not have enough properties" % (instance,),
)
@@ -455,14 +455,14 @@ def oneOf(validator, oneOf, instance, schema):
more_valid.append(first_valid)
reprs = ", ".join(repr(schema) for schema in more_valid)
yield ValidationError(
- "%r is valid under each of %s" % (instance, reprs)
+ "%r is valid under each of %s" % (instance, reprs),
)
def not_(validator, not_schema, instance, schema):
if validator.is_valid(instance, not_schema):
yield ValidationError(
- "%r is not allowed for %r" % (not_schema, instance)
+ "%r is not allowed for %r" % (not_schema, instance),
)
@@ -480,13 +480,13 @@ def if_(validator, if_schema, instance, schema):
def unevaluatedItems(validator, unevaluatedItems, instance, schema):
evaluated_item_indexes = find_evaluated_item_indexes_by_schema(
- validator, instance, schema
+ validator, instance, schema,
)
unevaluated_items = []
for k, v in enumerate(instance):
if k not in evaluated_item_indexes:
for error in validator.descend(
- v, unevaluatedItems, schema_path="unevaluatedItems"
+ v, unevaluatedItems, schema_path="unevaluatedItems",
):
unevaluated_items.append(v)
@@ -497,7 +497,7 @@ def unevaluatedItems(validator, unevaluatedItems, instance, schema):
def unevaluatedProperties(validator, unevaluatedProperties, instance, schema):
evaluated_property_keys = find_evaluated_property_keys_by_schema(
- validator, instance, schema
+ validator, instance, schema,
)
unevaluated_property_keys = []
for property, subschema in instance.items():
@@ -521,6 +521,6 @@ def prefixItems(validator, prefixItems, instance, schema):
for k, v in enumerate(instance[:min(len(prefixItems), len(instance))]):
for error in validator.descend(
- v, prefixItems[k], schema_path="prefixItems"
+ v, prefixItems[k], schema_path="prefixItems",
):
yield error
diff --git a/jsonschema/cli.py b/jsonschema/cli.py
index a6ca43c..cfad6d1 100644
--- a/jsonschema/cli.py
+++ b/jsonschema/cli.py
@@ -201,7 +201,7 @@ def parse_args(args):
arguments = vars(parser.parse_args(args=args or ["--help"]))
if arguments["output"] != "plain" and arguments["error_format"]:
raise parser.error(
- "--error-format can only be used with --output plain"
+ "--error-format can only be used with --output plain",
)
if arguments["output"] == "plain" and arguments["error_format"] is None:
arguments["error_format"] = "{error.instance}: {error.message}\n"
diff --git a/jsonschema/exceptions.py b/jsonschema/exceptions.py
index 7f203cc..9cfbb7f 100644
--- a/jsonschema/exceptions.py
+++ b/jsonschema/exceptions.py
@@ -75,7 +75,7 @@ class _Error(Exception):
On %s%s:
%s
- """.rstrip()
+ """.rstrip(),
) % (
self.validator,
self._word_for_schema_in_error_message,
@@ -194,7 +194,7 @@ class UnknownType(Exception):
While checking instance:
%s
- """.rstrip()
+ """.rstrip(),
) % (
self.type,
textwrap.indent(pschema, " "),
diff --git a/jsonschema/tests/_suite.py b/jsonschema/tests/_suite.py
index 4d21f98..1c61363 100644
--- a/jsonschema/tests/_suite.py
+++ b/jsonschema/tests/_suite.py
@@ -143,7 +143,7 @@ class Version(object):
case_description=each["description"],
schema=each["schema"],
remotes=self._remotes,
- **test
+ **test,
) for test in each["tests"]
)
@@ -177,7 +177,7 @@ class _Test(object):
self.subject,
self.case_description,
self.description,
- ]
+ ],
)
@property
@@ -213,7 +213,7 @@ class _Test(object):
schema=self.schema,
cls=Validator,
resolver=resolver,
- **kwargs
+ **kwargs,
)
def validate_ignoring_errors(self, Validator): # pragma: no cover
diff --git a/jsonschema/tests/test_cli.py b/jsonschema/tests/test_cli.py
index ae4f13d..fa29b48 100644
--- a/jsonschema/tests/test_cli.py
+++ b/jsonschema/tests/test_cli.py
@@ -59,7 +59,7 @@ def _message_for(non_json):
class TestCLI(TestCase):
def run_cli(
- self, argv, files={}, stdin=StringIO(), exit_code=0, **override
+ self, argv, files={}, stdin=StringIO(), exit_code=0, **override,
):
arguments = cli.parse_args(argv)
arguments.update(override)
@@ -134,7 +134,7 @@ class TestCLI(TestCase):
I am an error!
-----------------------------
""",
- ),
+ )
def test_invalid_instance_explicit_plain_output(self):
error = ValidationError("I am an error!", instance=12)
@@ -835,7 +835,7 @@ class TestParser(TestCase):
"jsonschema.tests.test_cli.TestParser.FakeValidator",
"--instance", "mem://some/instance",
"mem://some/schema",
- ]
+ ],
)
self.assertIs(arguments["validator"], self.FakeValidator)
@@ -845,7 +845,7 @@ class TestParser(TestCase):
"--validator", "Draft4Validator",
"--instance", "mem://some/instance",
"mem://some/schema",
- ]
+ ],
)
self.assertIs(arguments["validator"], Draft4Validator)
@@ -857,7 +857,7 @@ class TestParser(TestCase):
[
"--output", "foo",
"mem://some/schema",
- ]
+ ],
)
self.assertIn("invalid choice: 'foo'", stderr.getvalue())
self.assertFalse(stdout.getvalue())
@@ -871,7 +871,7 @@ class TestParser(TestCase):
"--output", "pretty",
"--error-format", "foo",
"mem://some/schema",
- ]
+ ],
)
self.assertIn(
"--error-format can only be used with --output plain",
diff --git a/jsonschema/tests/test_exceptions.py b/jsonschema/tests/test_exceptions.py
index a285550..788d316 100644
--- a/jsonschema/tests/test_exceptions.py
+++ b/jsonschema/tests/test_exceptions.py
@@ -41,7 +41,7 @@ class TestBestMatch(TestCase):
"minProperties": 2,
"anyOf": [{"type": "string"}, {"type": "number"}],
"oneOf": [{"type": "string"}, {"type": "number"}],
- }
+ },
)
best = self.best_match(validator.iter_errors({}))
self.assertEqual(best.validator, "minProperties")
diff --git a/jsonschema/tests/test_format.py b/jsonschema/tests/test_format.py
index 06f841c..1846cb2 100644
--- a/jsonschema/tests/test_format.py
+++ b/jsonschema/tests/test_format.py
@@ -40,7 +40,7 @@ class TestFormatChecker(TestCase):
checker.checks("boom")(boom)
self.assertEqual(
checker.checkers,
- dict(FormatChecker.checkers, boom=(boom, ()))
+ dict(FormatChecker.checkers, boom=(boom, ())),
)
def test_it_catches_registered_errors(self):
@@ -102,6 +102,6 @@ class TestFormatChecker(TestCase):
checker = FormatChecker()
self.assertTrue(checker.conforms(1, "uuid"))
self.assertTrue(
- checker.conforms("6e6659ec-4503-4428-9f03-2e2ea4d6c278", "uuid")
+ checker.conforms("6e6659ec-4503-4428-9f03-2e2ea4d6c278", "uuid"),
)
self.assertFalse(checker.conforms("test", "uuid"))
diff --git a/jsonschema/tests/test_jsonschema_test_suite.py b/jsonschema/tests/test_jsonschema_test_suite.py
index b1e0723..1d8a804 100644
--- a/jsonschema/tests/test_jsonschema_test_suite.py
+++ b/jsonschema/tests/test_jsonschema_test_suite.py
@@ -459,5 +459,5 @@ TestDraft202012Format = DRAFT202012.to_unittest_testcase(
or leap_second(test)
or missing_format(draft202012_format_checker)(test)
or complex_email_validation(test)
- )
+ ),
)
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py
index bb3fefb..65969bd 100644
--- a/jsonschema/tests/test_validators.py
+++ b/jsonschema/tests/test_validators.py
@@ -288,7 +288,7 @@ class TestValidationErrorMessages(TestCase):
def test_additionalItems_multiple_failures(self):
message = self.message_for(
instance=[1, 2, 3],
- schema={u"items": [], u"additionalItems": False}
+ schema={u"items": [], u"additionalItems": False},
)
self.assertIn("(1, 2, 3 were unexpected)", message)
@@ -371,7 +371,7 @@ class TestValidationErrorMessages(TestCase):
self.assertEqual(
message,
"{}, {} do not match any of the regexes: {}, {}".format(
- repr(u"fish"), repr(u"zebra"), repr(u"^abc$"), repr(u"^def$")
+ repr(u"fish"), repr(u"zebra"), repr(u"^abc$"), repr(u"^def$"),
),
)
@@ -384,10 +384,7 @@ class TestValidationErrorMessages(TestCase):
self.assertIn("False schema does not allow 'something'", message)
def test_unevaluated_properties(self):
- schema = {
- "type": "object",
- "unevaluatedProperties": False
- }
+ schema = {"type": "object", "unevaluatedProperties": False}
message = self.message_for(
instance={
"foo": "foo",
@@ -403,10 +400,7 @@ class TestValidationErrorMessages(TestCase):
)
def test_unevaluated_items(self):
- schema = {
- "type": "array",
- "unevaluatedItems": False
- }
+ schema = {"type": "array", "unevaluatedItems": False}
message = self.message_for(
instance=["foo", "bar"],
schema=schema,
@@ -654,7 +648,7 @@ class TestValidationErrorDetails(TestCase):
)
self.assertEqual(
list(e5.schema_path),
- ["items", "properties", "bar", "properties", "baz", "minItems"]
+ ["items", "properties", "bar", "properties", "baz", "minItems"],
)
self.assertEqual(
list(e6.schema_path), ["items", "properties", "foo", "enum"],
@@ -1047,7 +1041,7 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object):
lambda checker, thing: isinstance(
thing, (int, float, Decimal),
) and not isinstance(thing, bool),
- )
+ ),
)
validator = Validator(schema)
@@ -1101,7 +1095,7 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object):
type_checker=self.Validator.TYPE_CHECKER.redefine(
non_string_type,
lambda checker, thing: isinstance(thing, int),
- )
+ ),
)
Crazy(schema).validate(15)
@@ -1116,7 +1110,7 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object):
type_checker=self.Validator.TYPE_CHECKER.redefine(
"array",
lambda checker, thing: isinstance(thing, tuple),
- )
+ ),
)
with self.assertRaises(exceptions.ValidationError) as e:
TupleValidator({"uniqueItems": True}).validate((1, 1))
@@ -1126,21 +1120,20 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object):
"""
Allow array to validate against another defined sequence type
"""
- schema = {
- "type": "array",
- "uniqueItems": True
- }
+ schema = {"type": "array", "uniqueItems": True}
MyMapping = namedtuple('MyMapping', 'a, b')
Validator = validators.extend(
self.Validator,
- type_checker=self.Validator.TYPE_CHECKER.redefine_many({
- "array": lambda checker, thing: isinstance(
- thing, (list, deque)
- ),
- "object": lambda checker, thing: isinstance(
- thing, (dict, MyMapping)
- ),
- })
+ type_checker=self.Validator.TYPE_CHECKER.redefine_many(
+ {
+ "array": lambda checker, thing: isinstance(
+ thing, (list, deque),
+ ),
+ "object": lambda checker, thing: isinstance(
+ thing, (dict, MyMapping),
+ ),
+ },
+ ),
)
validator = Validator(schema)
@@ -1154,15 +1147,11 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object):
[MyMapping('a', 0), MyMapping('a', False)],
[
MyMapping('a', [deque([0])]),
- MyMapping('a', [deque([False])])
+ MyMapping('a', [deque([False])]),
],
[
- MyMapping('a', [
- MyMapping('a', deque([0]))
- ]),
- MyMapping('a', [
- MyMapping('a', deque([False]))
- ])
+ MyMapping('a', [MyMapping('a', deque([0]))]),
+ MyMapping('a', [MyMapping('a', deque([False]))]),
],
[deque(deque(deque([False]))), deque(deque(deque([0])))],
]
@@ -1180,15 +1169,11 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object):
[MyMapping('a', False), MyMapping('a', False)],
[
MyMapping('a', [deque([False])]),
- MyMapping('a', [deque([False])])
+ MyMapping('a', [deque([False])]),
],
[
- MyMapping('a', [
- MyMapping('a', deque([False]))
- ]),
- MyMapping('a', [
- MyMapping('a', deque([False]))
- ])
+ MyMapping('a', [MyMapping('a', deque([False]))]),
+ MyMapping('a', [MyMapping('a', deque([False]))]),
],
[deque(deque(deque([False]))), deque(deque(deque([False])))],
]
@@ -1245,7 +1230,7 @@ class TestDraft3Validator(AntiDraft6LeakMixin, ValidatorTestMixin, TestCase):
self.Validator,
type_checker=self.Validator.TYPE_CHECKER.redefine(
"any", lambda checker, thing: isinstance(thing, int),
- )
+ ),
)
validator = Crazy({"type": "any"})
validator.validate(12)
@@ -1408,7 +1393,7 @@ class TestValidatorFor(SynchronousTestCase):
)
def test_does_not_warn_if_meta_schema_is_unspecified(self):
- validators.validator_for(schema={}, default={}),
+ validators.validator_for(schema={}, default={})
self.assertFalse(self.flushWarnings())
@@ -1466,14 +1451,14 @@ class TestValidate(SynchronousTestCase):
def test_draft202012_validator_is_chosen(self):
self.assertUses(
schema={
- "$schema": "https://json-schema.org/draft/2020-12/schema#"
+ "$schema": "https://json-schema.org/draft/2020-12/schema#",
},
Validator=validators.Draft202012Validator,
)
# Make sure it works without the empty fragment
self.assertUses(
schema={
- "$schema": "https://json-schema.org/draft/2020-12/schema"
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
},
Validator=validators.Draft202012Validator,
)
diff --git a/jsonschema/validators.py b/jsonschema/validators.py
index 7a07415..9e6bf1e 100644
--- a/jsonschema/validators.py
+++ b/jsonschema/validators.py
@@ -615,7 +615,7 @@ class RefResolver(object):
raise exceptions.RefResolutionError(
"Failed to pop the scope from an empty stack. "
"`pop_scope()` should only be called once for every "
- "`push_scope()`"
+ "`push_scope()`",
)
@property
@@ -692,7 +692,7 @@ class RefResolver(object):
for subschema in self._finditem(schema, "$id"):
target_uri = self._urljoin_cache(
- self.resolution_scope, subschema['$id']
+ self.resolution_scope, subschema['$id'],
)
if target_uri.rstrip("/") == uri.rstrip("/"):
if fragment:
@@ -764,7 +764,7 @@ class RefResolver(object):
document = document[part]
except (TypeError, LookupError):
raise exceptions.RefResolutionError(
- "Unresolvable JSON pointer: %r" % fragment
+ "Unresolvable JSON pointer: %r" % fragment,
)
return document
diff --git a/tox.ini b/tox.ini
index 7e31b7e..33de1aa 100644
--- a/tox.ini
+++ b/tox.ini
@@ -83,6 +83,7 @@ commands = {envbindir}/detect-secrets scan {toxinidir}
[testenv:style]
deps =
flake8
+ flake8-commas
commands =
{envpython} -m flake8 {posargs} {toxinidir}/jsonschema {toxinidir}/docs