Skip to content

Commit d8744fe

Browse files
committed
Enable another ruff ruleset.
1 parent 8dbcf2a commit d8744fe

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

jsonschema/_format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class FormatChecker:
4545
checkers: dict[
4646
str,
4747
tuple[_FormatCheckCallable, _RaisesType],
48-
] = {}
48+
] = {} # noqa: RUF012
4949

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

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

8080
def _checks(func: _F) -> _F:
8181
self.checkers[format] = (func, raises)

jsonschema/tests/test_deprecations.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_version(self):
1616

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

2121
self.assertEqual(w.filename, __file__)
2222

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

2929
message = "Importing ErrorTree from jsonschema.validators is "
3030
with self.assertWarnsRegex(DeprecationWarning, message) as w:
31-
from jsonschema.validators import ErrorTree # noqa
31+
from jsonschema.validators import ErrorTree
3232

3333
self.assertEqual(ErrorTree, exceptions.ErrorTree)
3434
self.assertEqual(w.filename, __file__)
@@ -41,7 +41,7 @@ def test_import_ErrorTree(self):
4141

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

4646
self.assertEqual(ErrorTree, exceptions.ErrorTree)
4747
self.assertEqual(w.filename, __file__)
@@ -54,7 +54,7 @@ def test_import_FormatError(self):
5454

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

5959
self.assertEqual(FormatError, exceptions.FormatError)
6060
self.assertEqual(w.filename, __file__)
@@ -145,7 +145,7 @@ def test_RefResolver(self):
145145

146146
message = "jsonschema.RefResolver is deprecated"
147147
with self.assertWarnsRegex(DeprecationWarning, message) as w:
148-
from jsonschema import RefResolver # noqa: F401
148+
from jsonschema import RefResolver
149149
self.assertEqual(w.filename, __file__)
150150

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

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

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

168168
with self.assertWarnsRegex(DeprecationWarning, message) as w:
169-
from jsonschema.exceptions import RefResolutionError # noqa
169+
from jsonschema.exceptions import RefResolutionError
170170

171171
self.assertEqual(RefResolutionError, exceptions._RefResolutionError)
172172
self.assertEqual(w.filename, __file__)
@@ -274,7 +274,7 @@ def test_draftN_format_checker(self):
274274

275275
message = "Accessing jsonschema.draft202012_format_checker is "
276276
with self.assertWarnsRegex(DeprecationWarning, message) as w:
277-
from jsonschema import draft202012_format_checker # noqa
277+
from jsonschema import draft202012_format_checker
278278

279279
self.assertIs(
280280
draft202012_format_checker,
@@ -284,7 +284,7 @@ def test_draftN_format_checker(self):
284284

285285
message = "Accessing jsonschema.draft201909_format_checker is "
286286
with self.assertWarnsRegex(DeprecationWarning, message) as w:
287-
from jsonschema import draft201909_format_checker # noqa
287+
from jsonschema import draft201909_format_checker
288288

289289
self.assertIs(
290290
draft201909_format_checker,
@@ -294,7 +294,7 @@ def test_draftN_format_checker(self):
294294

295295
message = "Accessing jsonschema.draft7_format_checker is "
296296
with self.assertWarnsRegex(DeprecationWarning, message) as w:
297-
from jsonschema import draft7_format_checker # noqa
297+
from jsonschema import draft7_format_checker
298298

299299
self.assertIs(
300300
draft7_format_checker,
@@ -304,7 +304,7 @@ def test_draftN_format_checker(self):
304304

305305
message = "Accessing jsonschema.draft6_format_checker is "
306306
with self.assertWarnsRegex(DeprecationWarning, message) as w:
307-
from jsonschema import draft6_format_checker # noqa
307+
from jsonschema import draft6_format_checker
308308

309309
self.assertIs(
310310
draft6_format_checker,
@@ -314,7 +314,7 @@ def test_draftN_format_checker(self):
314314

315315
message = "Accessing jsonschema.draft4_format_checker is "
316316
with self.assertWarnsRegex(DeprecationWarning, message) as w:
317-
from jsonschema import draft4_format_checker # noqa
317+
from jsonschema import draft4_format_checker
318318

319319
self.assertIs(
320320
draft4_format_checker,
@@ -324,7 +324,7 @@ def test_draftN_format_checker(self):
324324

325325
message = "Accessing jsonschema.draft3_format_checker is "
326326
with self.assertWarnsRegex(DeprecationWarning, message) as w:
327-
from jsonschema import draft3_format_checker # noqa
327+
from jsonschema import draft3_format_checker
328328

329329
self.assertIs(
330330
draft3_format_checker,

jsonschema/tests/test_validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,7 +2393,7 @@ def test_pointer_within_schema_with_different_id(self):
23932393
def test_newly_created_validator_with_ref_resolver(self):
23942394
"""
23952395
See https://github.com/python-jsonschema/jsonschema/issues/1061#issuecomment-1624266555.
2396-
""" # noqa: E501
2396+
"""
23972397

23982398
def handle(uri):
23992399
self.assertEqual(uri, "http://example.com/foo")
@@ -2414,7 +2414,7 @@ def handle(uri):
24142414
def test_refresolver_with_pointer_in_schema_with_no_id(self):
24152415
"""
24162416
See https://github.com/python-jsonschema/jsonschema/issues/1124#issuecomment-1632574249.
2417-
""" # noqa: E501
2417+
"""
24182418

24192419
schema = {
24202420
"properties": {"x": {"$ref": "#/definitions/x"}},

jsonschema/validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ def create(
213213
@define
214214
class Validator:
215215

216-
VALIDATORS = dict(validators)
217-
META_SCHEMA = dict(meta_schema)
216+
VALIDATORS = dict(validators) # noqa: RUF012
217+
META_SCHEMA = dict(meta_schema) # noqa: RUF012
218218
TYPE_CHECKER = type_checker
219219
FORMAT_CHECKER = format_checker_arg
220220
ID_OF = staticmethod(id_of)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ exclude = ["jsonschema/benchmarks/*"]
141141
[tool.ruff]
142142
line-length = 79
143143
target-version = "py38"
144-
select = ["B", "D", "D204", "E", "F", "Q", "SIM", "UP", "W"]
144+
select = ["B", "D", "D204", "E", "F", "Q", "RUF", "SIM", "UP", "W"]
145145
ignore = [
146146
# Wat, type annotations for self and cls, why is this a thing?
147147
"ANN101",
@@ -182,4 +182,4 @@ docstring-quotes = "double"
182182
"jsonschema/cli.py" = ["D", "SIM", "UP"]
183183
"jsonschema/_utils.py" = ["D"]
184184
"jsonschema/benchmarks/*" = ["D"]
185-
"jsonschema/tests/*" = ["ANN", "D", "SIM"]
185+
"jsonschema/tests/*" = ["ANN", "D", "RUF012", "SIM"]

0 commit comments

Comments
 (0)