@@ -64,16 +64,20 @@ def is_any(checker, instance):
6464@attr .s (frozen = True )
6565class TypeChecker :
6666 """
67- A `` type` ` property checker.
67+ A :kw:` type` property checker.
6868
69- A `TypeChecker` performs type checking for a `Validator`. Type
70- checks to perform are updated using `TypeChecker.redefine` or
71- `TypeChecker.redefine_many` and removed via `TypeChecker.remove`.
72- Each of these return a new `TypeChecker` object.
69+ A `TypeChecker` performs type checking for a `Validator`, converting
70+ between the defined JSON Schema types and some associated Python types or
71+ objects.
72+
73+ Modifying the behavior just mentioned by redefining which Python objects
74+ are considered to be of which JSON Schema types can be done using
75+ `TypeChecker.redefine` or `TypeChecker.redefine_many`, and types can be
76+ removed via `TypeChecker.remove`. Each of these return a new `TypeChecker`.
7377
7478 Arguments:
7579
76- type_checkers (dict) :
80+ type_checkers:
7781
7882 The initial mapping of types to their checking functions.
7983 """
@@ -85,25 +89,20 @@ class TypeChecker:
8589 converter = _typed_pmap_converter ,
8690 )
8791
88- def is_type (self , instance , type ) :
92+ def is_type (self , instance , type : str ) -> bool :
8993 """
9094 Check if the instance is of the appropriate type.
9195
9296 Arguments:
9397
94- instance (object) :
98+ instance:
9599
96100 The instance to check
97101
98- type (str) :
102+ type:
99103
100104 The name of the type that is expected.
101105
102- Returns:
103-
104- bool: Whether it conformed.
105-
106-
107106 Raises:
108107
109108 `jsonschema.exceptions.UndefinedTypeCheck`:
@@ -117,30 +116,26 @@ def is_type(self, instance, type):
117116
118117 return fn (self , instance )
119118
120- def redefine (self , type , fn ):
119+ def redefine (self , type : str , fn ) -> "TypeChecker" :
121120 """
122121 Produce a new checker with the given type redefined.
123122
124123 Arguments:
125124
126- type (str) :
125+ type:
127126
128127 The name of the type to check.
129128
130129 fn (collections.abc.Callable):
131130
132- A function taking exactly two parameters - the type
131+ A callable taking exactly two parameters - the type
133132 checker calling the function and the instance to check.
134133 The function should return true if instance is of this
135134 type and false otherwise.
136-
137- Returns:
138-
139- A new `TypeChecker` instance.
140135 """
141136 return self .redefine_many ({type : fn })
142137
143- def redefine_many (self , definitions = ()):
138+ def redefine_many (self , definitions = ()) -> "TypeChecker" :
144139 """
145140 Produce a new checker with the given types redefined.
146141
@@ -149,28 +144,20 @@ def redefine_many(self, definitions=()):
149144 definitions (dict):
150145
151146 A dictionary mapping types to their checking functions.
152-
153- Returns:
154-
155- A new `TypeChecker` instance.
156147 """
157148 type_checkers = self ._type_checkers .update (definitions )
158149 return attr .evolve (self , type_checkers = type_checkers )
159150
160- def remove (self , * types ):
151+ def remove (self , * types ) -> "TypeChecker" :
161152 """
162153 Produce a new checker with the given types forgotten.
163154
164155 Arguments:
165156
166- types (~collections.abc.Iterable) :
157+ types:
167158
168159 the names of the types to remove.
169160
170- Returns:
171-
172- A new `TypeChecker` instance
173-
174161 Raises:
175162
176163 `jsonschema.exceptions.UndefinedTypeCheck`:
0 commit comments