Skip to content

Commit fd491f9

Browse files
committed
Minor non-functional changes to FormatChecker docstrings and __init__.
1 parent a513c99 commit fd491f9

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

docs/validate.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ By default, no validation is enforced, but optionally, validation can be enabled
191191
:exclude-members: cls_checks
192192

193193
.. attribute:: checkers
194+
194195
A mapping of currently known formats to tuple of functions that validate them and errors that should be caught.
195196
New checkers can be added and removed either per-instance or globally for all checkers using the `FormatChecker.checks` decorator.
196197

jsonschema/_format.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ class FormatChecker:
2828
`FormatChecker` objects always return ``True`` when asked about
2929
formats that they do not know how to validate.
3030
31-
To check a custom format using a function that takes an instance and
32-
returns a ``bool``, use the `FormatChecker.checks` or
33-
`FormatChecker.cls_checks` decorators.
31+
To add a check for a custom format use the `FormatChecker.checks`
32+
decorator.
3433
3534
Arguments:
3635
37-
formats (~collections.abc.Iterable):
36+
formats:
3837
3938
The known formats to validate. This argument can be used to
4039
limit which formats will be used during validation.
@@ -47,9 +46,8 @@ class FormatChecker:
4746

4847
def __init__(self, formats: typing.Iterable[str] | None = None):
4948
if formats is None:
50-
self.checkers = self.checkers.copy()
51-
else:
52-
self.checkers = dict((k, self.checkers[k]) for k in formats)
49+
formats = self.checkers.keys()
50+
self.checkers = {k: self.checkers[k] for k in formats}
5351

5452
def __repr__(self):
5553
return "<FormatChecker checkers={}>".format(sorted(self.checkers))
@@ -62,11 +60,11 @@ def checks(
6260
6361
Arguments:
6462
65-
format (str):
63+
format:
6664
6765
The format that the decorated function will check.
6866
69-
raises (Exception):
67+
raises:
7068
7169
The exception(s) raised by the decorated function when an
7270
invalid instance is found.
@@ -117,7 +115,7 @@ def check(self, instance: object, format: str) -> None:
117115
118116
The instance to check
119117
120-
format (str):
118+
format:
121119
122120
The format that instance should conform to
123121
@@ -150,7 +148,7 @@ def conforms(self, instance: object, format: str) -> bool:
150148
151149
The instance to check
152150
153-
format (str):
151+
format:
154152
155153
The format that instance should conform to
156154

0 commit comments

Comments
 (0)