Commit a7be716
committed
Update jsonschema stubs to track latest changes
In python-jsonschema/jsonschema#1396 , the type signature for
`Validator.__init__` is updated to better match the runtime signature.
This backports the fix to typeshed, keeping the copies of this data in
sync. python-jsonschema/jsonschema#1396 is, itself, a response to
feedback on `jsonschema` about the changes in `typeshed` python#14327.
In addition to the `__init__` fix, a couple of additional small changes
are made, both in `jsonschema` and here in the stubs:
1. In `jsonschema`, the type for `create()` in `validators.py` was
updated to be notated with `-> type[Validator]`. This was necessary
for internal testing on types to correctly read that validator
classes created by this factory implement the protocol.
2. Here, in order to better guarantee that the types align, the
`_Validator` class (which does not exist in `jsonschema`, but is only
defined here in the stubs) now inherits from `Validator`.
3. The init signature for `_Validator` is updated to match
4. `tests/mypy_test.py` flags the `schema` instance variable annotation
as mismatching between `Validator` and `_Validator`. Review against
the `jsonschema` source reveals that `_Validator` was closer to
correct, so `Validator` is fixed to match.
Any further changes (e.g., elimination of `_Validator` or changing
`create`'s return type annotation) are left as potential future work.1 parent d270bb0 commit a7be716
2 files changed
+9
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
0 commit comments