Skip to content

Commit 636dbf8

Browse files
committed
Fix ruff deprecation noise and style changes.
1 parent cceab53 commit 636dbf8

File tree

7 files changed

+31
-3
lines changed

7 files changed

+31
-3
lines changed

jsonschema/_format.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class FormatChecker:
4040
4141
The known formats to validate. This argument can be used to
4242
limit which formats will be used during validation.
43+
4344
"""
4445

4546
checkers: dict[
@@ -75,6 +76,7 @@ def checks(
7576
The exception object will be accessible as the
7677
`jsonschema.exceptions.ValidationError.cause` attribute of the
7778
resulting validation error.
79+
7880
"""
7981

8082
def _checks(func: _F) -> _F:
@@ -127,6 +129,7 @@ def check(self, instance: object, format: str) -> None:
127129
FormatError:
128130
129131
if the instance does not conform to ``format``
132+
130133
"""
131134
if format not in self.checkers:
132135
return
@@ -157,6 +160,7 @@ def conforms(self, instance: object, format: str) -> bool:
157160
Returns:
158161
159162
bool: whether it conformed
163+
160164
"""
161165
try:
162166
self.check(instance, format)

jsonschema/_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class TypeChecker:
7676
type_checkers:
7777
7878
The initial mapping of types to their checking functions.
79+
7980
"""
8081

8182
_type_checkers: HashTrieMap[
@@ -105,6 +106,7 @@ def is_type(self, instance, type: str) -> bool:
105106
`jsonschema.exceptions.UndefinedTypeCheck`:
106107
107108
if ``type`` is unknown to this object.
109+
108110
"""
109111
try:
110112
fn = self._type_checkers[type]
@@ -129,6 +131,7 @@ def redefine(self, type: str, fn) -> TypeChecker:
129131
checker calling the function and the instance to check.
130132
The function should return true if instance is of this
131133
type and false otherwise.
134+
132135
"""
133136
return self.redefine_many({type: fn})
134137

@@ -141,6 +144,7 @@ def redefine_many(self, definitions=()) -> TypeChecker:
141144
definitions (dict):
142145
143146
A dictionary mapping types to their checking functions.
147+
144148
"""
145149
type_checkers = self._type_checkers.update(definitions)
146150
return evolve(self, type_checkers=type_checkers)
@@ -160,6 +164,7 @@ def remove(self, *types) -> TypeChecker:
160164
`jsonschema.exceptions.UndefinedTypeCheck`:
161165
162166
if any given type is unknown to this object
167+
163168
"""
164169
type_checkers = self._type_checkers
165170
for each in types:

jsonschema/_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def format_as_index(container, indices):
5959
indices (sequence):
6060
6161
The indices to format.
62+
6263
"""
6364
if not indices:
6465
return container

jsonschema/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ def by_relevance(weak=WEAK_MATCHES, strong=STRONG_MATCHES):
390390
strong (set):
391391
a collection of validation keywords to consider to be
392392
"strong"
393+
393394
"""
394395

395396
def relevance(error):
@@ -453,6 +454,7 @@ def best_match(errors, key=relevance):
453454
454455
This function is a heuristic. Its return value may change for a given
455456
set of inputs from version to version if better heuristics are added.
457+
456458
"""
457459
errors = iter(errors)
458460
best = next(errors, None)

jsonschema/protocols.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Validator(Protocol):
8686
8787
Subclassing validator classes now explicitly warns this is not part of
8888
their public API.
89+
8990
"""
9091

9192
#: An object representing the validator's meta schema (the schema that
@@ -129,6 +130,7 @@ def check_schema(cls, schema: Mapping | bool) -> None:
129130
`jsonschema.exceptions.SchemaError`:
130131
131132
if the schema is invalid
133+
132134
"""
133135

134136
def is_type(self, instance: Any, type: str) -> bool:
@@ -154,6 +156,7 @@ def is_type(self, instance: Any, type: str) -> bool:
154156
`jsonschema.exceptions.UnknownType`:
155157
156158
if ``type`` is not a known type
159+
157160
"""
158161

159162
def is_valid(self, instance: Any) -> bool:
@@ -167,6 +170,7 @@ def is_valid(self, instance: Any) -> bool:
167170
>>> schema = {"maxItems" : 2}
168171
>>> Draft202012Validator(schema).is_valid([2, 3, 4])
169172
False
173+
170174
"""
171175

172176
def iter_errors(self, instance: Any) -> Iterable[ValidationError]:
@@ -205,6 +209,7 @@ def validate(self, instance: Any) -> None:
205209
Traceback (most recent call last):
206210
...
207211
ValidationError: [2, 3, 4] is too long
212+
208213
"""
209214

210215
def evolve(self, **kwargs) -> Validator:

jsonschema/validators.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def validates(version):
9595
collections.abc.Callable:
9696
9797
a class decorator to decorate the validator with the version
98+
9899
"""
99100

100101
def _validates(cls):
@@ -209,6 +210,7 @@ def create(
209210
Returns:
210211
211212
a new `jsonschema.protocols.Validator` class
213+
212214
"""
213215
# preemptively don't shadow the `Validator.format_checker` local
214216
format_checker_arg = format_checker
@@ -566,6 +568,7 @@ def extend(
566568
class. Note that no implicit copying is done, so a copy should
567569
likely be made before modifying it, in order to not affect the
568570
old validator.
571+
569572
"""
570573
all_validators = dict(validator.VALIDATORS)
571574
all_validators.update(validators)
@@ -892,6 +895,7 @@ class _RefResolver:
892895
.. deprecated:: v4.18.0
893896
894897
``RefResolver`` has been deprecated in favor of `referencing`.
898+
895899
"""
896900

897901
_DEPRECATION_MESSAGE = (
@@ -961,6 +965,7 @@ def from_schema( # noqa: D417
961965
Returns:
962966
963967
`_RefResolver`
968+
964969
"""
965970
return cls(base_uri=id_of(schema) or "", referrer=schema, *args, **kwargs) # noqa: B026, E501
966971

@@ -1040,6 +1045,7 @@ def resolving(self, ref):
10401045
ref (str):
10411046
10421047
The reference to resolve
1048+
10431049
"""
10441050
url, resolved = self.resolve(ref)
10451051
self.push_scope(url)
@@ -1121,6 +1127,7 @@ def resolve_fragment(self, document, fragment):
11211127
fragment (str):
11221128
11231129
a URI fragment to resolve within it
1130+
11241131
"""
11251132
fragment = fragment.lstrip("/")
11261133

@@ -1190,6 +1197,7 @@ def resolve_remote(self, uri):
11901197
The retrieved document
11911198
11921199
.. _requests: https://pypi.org/project/requests/
1200+
11931201
"""
11941202
try:
11951203
import requests
@@ -1301,6 +1309,7 @@ def validate(instance, schema, cls=None, *args, **kwargs): # noqa: D417
13011309
.. rubric:: Footnotes
13021310
.. [#] known by a validator registered with
13031311
`jsonschema.validators.validates`
1312+
13041313
"""
13051314
if cls is None:
13061315
cls = validator_for(schema)

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ exclude = ["jsonschema/benchmarks/*"]
148148

149149
[tool.ruff]
150150
line-length = 79
151+
extend-exclude = ["json"]
152+
153+
[tool.ruff.lint]
151154
select = ["ALL"]
152155
ignore = [
153156
"A001", # It's fine to shadow builtins
@@ -196,19 +199,18 @@ ignore = [
196199
"TRY003", # Some exception classes are essentially intended for free-form
197200
"UP007", # We support 3.8 + 3.9
198201
]
199-
extend-exclude = ["json"]
200202

201203
[tool.ruff.lint.flake8-pytest-style]
202204
mark-parentheses = false
203205

204-
[tool.ruff.flake8-quotes]
206+
[tool.ruff.lint.flake8-quotes]
205207
docstring-quotes = "double"
206208

207209
[tool.ruff.lint.isort]
208210
combine-as-imports = true
209211
from-first = true
210212

211-
[tool.ruff.per-file-ignores]
213+
[tool.ruff.lint.per-file-ignores]
212214
"noxfile.py" = ["ANN", "D100", "S101", "T201"]
213215
"docs/*" = ["ANN", "D", "INP001"]
214216
"jsonschema/tests/*" = ["ANN", "D", "RUF012", "S", "PLR", "PYI024", "TRY"]

0 commit comments

Comments
 (0)