Add jsonschema.protocols.IValidator#890
Conversation
Codecov Report
@@ Coverage Diff @@
## main #890 +/- ##
==========================================
- Coverage 98.33% 98.25% -0.08%
==========================================
Files 19 20 +1
Lines 3125 3156 +31
Branches 378 425 +47
==========================================
+ Hits 3073 3101 +28
- Misses 41 44 +3
Partials 11 11
Continue to review full report at Codecov.
|
|
Thanks! This looks very much in the right direction. The only "significantish" thing that occurs to me is perhaps it'd be nice to also now add verification that validators implement this protocol to CI -- I'm out of the loop on whether we need a |
|
To keep us on the same page, here's the typeshed issue I just opened to discuss getting this added there:
I very much agree. Because I marked it Doing more sophisticated I'll look at setting up |
Yes that was all I was hoping for but I see you sent the other PR for mypy which is also nice of you, will have a look. I'm not a huge fan overall you can imagine otherwise I'd have done so myself previously but I'm perfectly happy (and appreciative) with what you've done there so will likely merge both of these. |
Julian
left a comment
There was a problem hiding this comment.
Thanks! Left some minor comments which you probably were addressing already.
There's also a .pyc file that snuck in here which you can please remove. After that should be good to merge, appreciated!
This is a Protocol implementation for type checking under mypy and other static analyzers. It uses the protocol class defined in py3.8+ and uses typing_extensions as a backport for py3.7 The documentation-only validator class has been replaced with the protocol, and docs are now driven via autoclass on the protocol. Importantly, several documented methods of the class have been removed, as they were marked deprecated under jsonschema v3.0 and are no longer provided by the builtin validators. Minor adjustments to the docs are made to repoint references at the new class definition.
Co-authored-by: Julian Berman <Julian@GrayVines.com>
Primarily, rewrite `IValidator` to `Validator` Co-authored-by: Julian Berman <Julian@GrayVines.com>
50831dd to
642a09f
Compare
|
Thanks for the suggestions; it made updating that much easier! Let me add a few tests for |
Several remaining cases referred to `IValidator` which is now just `Validtator`. Fix these. Add a test which ensures that all valdiators pass `isinstance(x, Validator)` using the runtime-checkable protocol.
This fixes `tox -e docs-style` `tox -e docs-linkcheck` is still failing (needs investigation)
|
I've added the tests I wanted and gotten most of the build passing. I'm stuck on I've fiddled with things a bit but couldn't get it to pass -- any help or feedback on how to make progress with that would be greatly appreciated. |
|
Thanks! I'll have a look in the morning, Linkcheck failing (but not others) would be odd, linkcheck should only fail (by itself) if it's an external link, but will have to have a look. Appreciated! |
|
Ah of course, linkcheck is failing because of the README change, which relies on RTD rebuilding the docs. That's fine we can merge and it will fail the first time but pass afterwards. Thanks again for sending the PR! |
I'm marking this as a draft. I wanted to share what I've got so far for #548, but I'm not certain that it's good to merge without checking in on typeshed to see what we should do there.
This is a Protocol implementation for type checking under mypy and other static analyzers. It uses the protocol class defined in py3.8+ and uses typing_extensions as a backport for py3.7
The documentation-only validator class has been replaced with the protocol, and docs are now driven via autoclass on the protocol.
Importantly, several documented methods of the class have been removed, as they were marked deprecated under jsonschema v3.0 and are no longer provided by the builtin validators.
Minor adjustments to the docs are made to repoint references at the new class definition.