Skip to content

Commit

Permalink
Enable another ruff ruleset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Jul 28, 2023
1 parent 8dbcf2a commit d8744fe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions jsonschema/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FormatChecker:
checkers: dict[
str,
tuple[_FormatCheckCallable, _RaisesType],
] = {}
] = {} # noqa: RUF012

def __init__(self, formats: typing.Iterable[str] | None = None):
if formats is None:
Expand All @@ -55,7 +55,7 @@ def __init__(self, formats: typing.Iterable[str] | None = None):
def __repr__(self):
return f"<FormatChecker checkers={sorted(self.checkers)}>"

def checks( # noqa: D417,D214,D405 (charliermarsh/ruff#3547)
def checks( # noqa: D417
self, format: str, raises: _RaisesType = (),
) -> typing.Callable[[_F], _F]:
"""
Expand All @@ -75,7 +75,7 @@ def checks( # noqa: D417,D214,D405 (charliermarsh/ruff#3547)
The exception object will be accessible as the
`jsonschema.exceptions.ValidationError.cause` attribute of the
resulting validation error.
""" # noqa: D417,D214,D405 (charliermarsh/ruff#3547)
""" # noqa: D214,D405 (charliermarsh/ruff#3547)

def _checks(func: _F) -> _F:
self.checkers[format] = (func, raises)
Expand Down
26 changes: 13 additions & 13 deletions jsonschema/tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_version(self):

message = "Accessing jsonschema.__version__ is deprecated"
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import __version__ # noqa
from jsonschema import __version__ # noqa: F401

self.assertEqual(w.filename, __file__)

Expand All @@ -28,7 +28,7 @@ def test_validators_ErrorTree(self):

message = "Importing ErrorTree from jsonschema.validators is "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema.validators import ErrorTree # noqa
from jsonschema.validators import ErrorTree

self.assertEqual(ErrorTree, exceptions.ErrorTree)
self.assertEqual(w.filename, __file__)
Expand All @@ -41,7 +41,7 @@ def test_import_ErrorTree(self):

message = "Importing ErrorTree directly from the jsonschema package "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import ErrorTree # noqa
from jsonschema import ErrorTree

self.assertEqual(ErrorTree, exceptions.ErrorTree)
self.assertEqual(w.filename, __file__)
Expand All @@ -54,7 +54,7 @@ def test_import_FormatError(self):

message = "Importing FormatError directly from the jsonschema package "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import FormatError # noqa
from jsonschema import FormatError

self.assertEqual(FormatError, exceptions.FormatError)
self.assertEqual(w.filename, __file__)
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_RefResolver(self):

message = "jsonschema.RefResolver is deprecated"
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import RefResolver # noqa: F401
from jsonschema import RefResolver
self.assertEqual(w.filename, __file__)

with self.assertWarnsRegex(DeprecationWarning, message) as w:
Expand All @@ -160,13 +160,13 @@ def test_RefResolutionError(self):

message = "jsonschema.exceptions.RefResolutionError is deprecated"
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import RefResolutionError # noqa: F401
from jsonschema import RefResolutionError

self.assertEqual(RefResolutionError, exceptions._RefResolutionError)
self.assertEqual(w.filename, __file__)

with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema.exceptions import RefResolutionError # noqa
from jsonschema.exceptions import RefResolutionError

self.assertEqual(RefResolutionError, exceptions._RefResolutionError)
self.assertEqual(w.filename, __file__)
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_draftN_format_checker(self):

message = "Accessing jsonschema.draft202012_format_checker is "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import draft202012_format_checker # noqa
from jsonschema import draft202012_format_checker

self.assertIs(
draft202012_format_checker,
Expand All @@ -284,7 +284,7 @@ def test_draftN_format_checker(self):

message = "Accessing jsonschema.draft201909_format_checker is "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import draft201909_format_checker # noqa
from jsonschema import draft201909_format_checker

self.assertIs(
draft201909_format_checker,
Expand All @@ -294,7 +294,7 @@ def test_draftN_format_checker(self):

message = "Accessing jsonschema.draft7_format_checker is "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import draft7_format_checker # noqa
from jsonschema import draft7_format_checker

self.assertIs(
draft7_format_checker,
Expand All @@ -304,7 +304,7 @@ def test_draftN_format_checker(self):

message = "Accessing jsonschema.draft6_format_checker is "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import draft6_format_checker # noqa
from jsonschema import draft6_format_checker

self.assertIs(
draft6_format_checker,
Expand All @@ -314,7 +314,7 @@ def test_draftN_format_checker(self):

message = "Accessing jsonschema.draft4_format_checker is "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import draft4_format_checker # noqa
from jsonschema import draft4_format_checker

self.assertIs(
draft4_format_checker,
Expand All @@ -324,7 +324,7 @@ def test_draftN_format_checker(self):

message = "Accessing jsonschema.draft3_format_checker is "
with self.assertWarnsRegex(DeprecationWarning, message) as w:
from jsonschema import draft3_format_checker # noqa
from jsonschema import draft3_format_checker

self.assertIs(
draft3_format_checker,
Expand Down
4 changes: 2 additions & 2 deletions jsonschema/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2393,7 +2393,7 @@ def test_pointer_within_schema_with_different_id(self):
def test_newly_created_validator_with_ref_resolver(self):
"""
See https://github.com/python-jsonschema/jsonschema/issues/1061#issuecomment-1624266555.
""" # noqa: E501
"""

def handle(uri):
self.assertEqual(uri, "http://example.com/foo")
Expand All @@ -2414,7 +2414,7 @@ def handle(uri):
def test_refresolver_with_pointer_in_schema_with_no_id(self):
"""
See https://github.com/python-jsonschema/jsonschema/issues/1124#issuecomment-1632574249.
""" # noqa: E501
"""

schema = {
"properties": {"x": {"$ref": "#/definitions/x"}},
Expand Down
4 changes: 2 additions & 2 deletions jsonschema/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def create(
@define
class Validator:

VALIDATORS = dict(validators)
META_SCHEMA = dict(meta_schema)
VALIDATORS = dict(validators) # noqa: RUF012
META_SCHEMA = dict(meta_schema) # noqa: RUF012
TYPE_CHECKER = type_checker
FORMAT_CHECKER = format_checker_arg
ID_OF = staticmethod(id_of)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ exclude = ["jsonschema/benchmarks/*"]
[tool.ruff]
line-length = 79
target-version = "py38"
select = ["B", "D", "D204", "E", "F", "Q", "SIM", "UP", "W"]
select = ["B", "D", "D204", "E", "F", "Q", "RUF", "SIM", "UP", "W"]
ignore = [
# Wat, type annotations for self and cls, why is this a thing?
"ANN101",
Expand Down Expand Up @@ -182,4 +182,4 @@ docstring-quotes = "double"
"jsonschema/cli.py" = ["D", "SIM", "UP"]
"jsonschema/_utils.py" = ["D"]
"jsonschema/benchmarks/*" = ["D"]
"jsonschema/tests/*" = ["ANN", "D", "SIM"]
"jsonschema/tests/*" = ["ANN", "D", "RUF012", "SIM"]

0 comments on commit d8744fe

Please sign in to comment.