Commit 58f2848
committed
Restrict --validator-class to types (no functions)
In order to better guarantee that `--validator-class` provides the
name of a `jsonschema.protocols.Validator` class, require that the
value passed is a type and not an alternative function.
This requirement does not lose significant expressive power and allows
us to more safely assume that the validator really is an
implementation of the protocol which can be extended with
`--fill-defaults` and other validator-related hooks.
There is no real way to guarantee the safety of using the user's
Validator. After all -- it could always raise an error at any time --
but this matches check-jsonschema's expectations about the argument
better.
This change can always be reverted in the future if there is
significant demand for a function-as-a-validator-class option.1 parent 11f7dfa commit 58f2848
File tree
2 files changed
+10
-44
lines changed- src/check_jsonschema/cli
- tests/unit
2 files changed
+10
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | 103 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 104 | + | |
116 | 105 | | |
117 | 106 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
338 | 313 | | |
339 | 314 | | |
340 | 315 | | |
| |||
343 | 318 | | |
344 | 319 | | |
345 | 320 | | |
346 | | - | |
| 321 | + | |
347 | 322 | | |
348 | 323 | | |
349 | 324 | | |
| |||
356 | 331 | | |
357 | 332 | | |
358 | 333 | | |
359 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
360 | 337 | | |
361 | 338 | | |
362 | 339 | | |
| |||
373 | 350 | | |
374 | 351 | | |
375 | 352 | | |
376 | | - | |
377 | | - | |
| 353 | + | |
| 354 | + | |
378 | 355 | | |
379 | 356 | | |
0 commit comments