@@ -28,13 +28,12 @@ class FormatChecker:
28
28
`FormatChecker` objects always return ``True`` when asked about
29
29
formats that they do not know how to validate.
30
30
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.
34
33
35
34
Arguments:
36
35
37
- formats (~collections.abc.Iterable) :
36
+ formats:
38
37
39
38
The known formats to validate. This argument can be used to
40
39
limit which formats will be used during validation.
@@ -47,9 +46,8 @@ class FormatChecker:
47
46
48
47
def __init__ (self , formats : typing .Iterable [str ] | None = None ):
49
48
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 }
53
51
54
52
def __repr__ (self ):
55
53
return "<FormatChecker checkers={}>" .format (sorted (self .checkers ))
@@ -62,11 +60,11 @@ def checks(
62
60
63
61
Arguments:
64
62
65
- format (str) :
63
+ format:
66
64
67
65
The format that the decorated function will check.
68
66
69
- raises (Exception) :
67
+ raises:
70
68
71
69
The exception(s) raised by the decorated function when an
72
70
invalid instance is found.
@@ -117,7 +115,7 @@ def check(self, instance: object, format: str) -> None:
117
115
118
116
The instance to check
119
117
120
- format (str) :
118
+ format:
121
119
122
120
The format that instance should conform to
123
121
@@ -150,7 +148,7 @@ def conforms(self, instance: object, format: str) -> bool:
150
148
151
149
The instance to check
152
150
153
- format (str) :
151
+ format:
154
152
155
153
The format that instance should conform to
156
154
0 commit comments