summaryrefslogtreecommitdiff
path: root/jsonschema/protocols.py
Commit message (Collapse)AuthorAgeFilesLines
* flake8 -> ruff, a mostly painless affair.Julian Berman2023-03-151-1/+1
|
* Remove a codepath meant for 3.7.Julian Berman2023-03-151-14/+8
| | | | (We no longer support it.)
* Newer attrs API in validators.py and some type hints for create.Julian Berman2023-03-151-2/+3
|
* Flail to get Sphinx to find references again.Julian Berman2023-02-211-5/+4
|
* Resolve $ref using the referencing library.Julian Berman2023-02-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | Passes all the remaining referencing tests across all drafts, hooray! Makes Validators take a referencing.Registry argument which users should use to customize preloaded schemas, or to configure remote reference retrieval. This fully obsoletes jsonschema.RefResolver, which has already been deprecated in a previous commit. Users should move to instead loading schemas into referencing.Registry objects. See the referencing documentation at https://referencing.rtfd.io/ for details (with more jsonschema-specific information to be added shortly). Note that the interface for resolving references on a Validator is not yet public (and hidden behind _resolver and _validate_reference attributes). One or both of these are likely to become public after some period of stabilization. Feedback is of course welcome!
* Deprecate Validator.resolver.Julian Berman2023-02-211-1/+5
| | | | | It will imminently be replaced by referencing.Registry-based resolution.
* Deprecate jsonschema.RefResolver from both places it is importable.Julian Berman2023-02-211-1/+1
| | | | | | Internal uses of it will be removed, replaced with referencing's resolution APIs, though RefResolver will continue to function during its deprecation period.
* Try fixing more Sphinx refs which fail only on Ubuntu...v4.17.2Julian Berman2022-11-291-1/+2
|
* Minor verbiage tweak for protocols.v4.15.0Julian Berman2022-08-311-2/+2
|
* Add some deprecated directives (for previous deprecations) to the docs.Julian Berman2022-08-301-0/+10
|
* Experiment with autoapi for generating explicit API documentation.Julian Berman2022-08-291-2/+1
| | | | Ref: #590
* Add ID_OF to the protocol, and schemas are arbitrary mappings.Julian Berman2022-08-211-6/+10
| | | | They aren't necessarily dicts.
* Standardize the format of Raises: in napolean docstrings.Julian Berman2022-08-201-3/+3
| | | | | | | | | | | | | | | Sphinx appears to 'helpfully' silently truncate the line if any text is put on the same line as the exception, i.e.: Raises: foo, if bar just silently produces: foo - and throws the line away...
* Convert more docs in protocols to napoleon.Julian Berman2022-08-201-26/+56
| | | | | Also rely more on sphinx's type annotation support, which seems to detect the argument types without duplicating.
* Fix mypy types for protocols.ValidatorJulian Berman2022-08-201-4/+4
| | | | | | | | | iter_errors returns an iterable, and doesn't guarantee it's an iterator (this is present in the text documentation). And instances are any Python object, not just dicts. (CC @sirosen just FYI and in case I made some silly error).
* Replace references to draft 3 in a few more doc examples.Julian Berman2022-08-161-3/+3
|
* Prefer 'keyword' over 'validator' in docs.Julian Berman2022-08-161-11/+11
| | | | | | | | | | | | | | In newer JSON Schema specifications we've standardized more on this language rather than calling things validators (and such a thing already has plenty of overloaded meaning here). This commit doesn't do any deprecation, so there's still some awkwardness in that ValidationError.validator is the keyword which failed validation, and Validator.VALIDATORS is a mapping of keywords to callables. We may choose to do so later, but for now will save some API churn in case something else changes.
* Add support for referencing schemas across different drafts.Julian Berman2022-08-161-0/+10
| | | | | | | | In other words, a draft 7 schema may reference a draft 2019 schema (or vice versa), and now correctly apply the 2019 rules within the referenced schema. Refs: json-schema-org/JSON-Schema-Test-Suite#587
* Add FORMAT_CHECKERTibor Völcker2022-01-161-0/+4
|
* Fix nitpick error on type annotationStephen Rosen2022-01-051-5/+10
| | | | | | | | | | | | | | | | | | | | | Nitpick was failing on TYPE_CHECKER: ClassVar[TypeChecker] It's not clear what to do about this. `TypeChecker` was imported correctly from `jsonschema._types` and is noted in the doc as `jsonschema.TypeChecker`. We can't import the `jsonschema` name at runtime because that would be circular. To resolve, use `typing.TYPE_CHECKING` to conditionally import `jsonschema` at type-checking time. This avoids the circular import but allows us to write TYPE_CHECKER: ClassVar[jsonschema.TypeChecker] As a result, Sphinx correctly builds a cross-reference from the annotation, the annotation is still accurate, and runtime behavior is left untouched.
* Use future import for type annotationsStephen Rosen2022-01-051-5/+7
| | | | | | | | | | | | | | Use of the `__future__` import of annotations allows several niceties, in particular: - parametrization of builtin types as generics - `|` syntax for unions (including `| None` for optionals) Update to use the future import wherever it improves or simplifies annotations. Avoid using new typing features outside of annotations (e.g. in assignment), which fails on older pythons. This is an unfortunate wart in the way that the future import works.
* Fix typing_extensions import handling for mypyStephen Rosen2022-01-051-2/+10
| | | | | | | mypy can handle `if sys.version_info` checking better than `try ... except ImportError`. This is somewhat disappointing, but the rewrite of these import lines isn't that bad and aligns with the recommendations of the mypy docs.
* Remove relative importsJulian Berman2021-12-151-4/+3
|
* Schemas can be bools too in newer drafts.Julian Berman2021-12-151-4/+4
|
* Apply suggestions from code reviewStephen Rosen2021-12-131-4/+5
| | | | | | Primarily, rewrite `IValidator` to `Validator` Co-authored-by: Julian Berman <Julian@GrayVines.com>
* Add `jsonschema.protocols.IValidator`Stephen Rosen2021-12-131-0/+152
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.