Skip to content

Commit

Permalink
Merge branch 'vendorize_jsonschema_w_tests' into main_wo_jsonschema
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Aug 2, 2023
1 parent edcf61f commit 14726b1
Show file tree
Hide file tree
Showing 646 changed files with 99,194 additions and 36 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ jobs:
python-version: 3.9
coverage: codecov

jsonschema:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
if: (github.repository == 'asdf-format/asdf' && (github.event_name == 'schedule' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'jsonschema')))
with:
submodules: false
# Any env name which does not start with `pyXY` will use this Python version.
default_python: '3.10'
envs: |
- linux: jsonschema
asdf-schemas:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ build
eggs
.eggs
parts
bin
var
sdist
develop-eggs
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude: "asdf/(extern||_jsonschema)/.*"
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -39,7 +40,7 @@ repos:
rev: '1.0.0'
hooks:
- id: flynt
exclude: "asdf/extern/.*"
exclude: "asdf/(extern||_jsonschema)/.*"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.280'
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The ASDF Standard is at v1.6.0
- Drop NumPy 1.20, 1.21 support [#1568]
- Convert numpy scalars to python types during yaml encoding
to handle NEP51 changes for numpy 2.0 [#1605]
- Vendorize jsonschema 4.17.3 [#1591]

2.15.0 (2023-03-28)
-------------------
Expand Down
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ There are two mailing lists for ASDF:
**F**\ ormat, information can be found
`here <https://seismic-data.org/>`__.

License
-------

ASDF is licensed under a BSD 3-clause style license. See `LICENSE.rst <LICENSE.rst>`_
for the `licenses folder <licenses>`_ for
licenses for any included software.

Contributing
------------

Expand Down
3 changes: 1 addition & 2 deletions asdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
]


from jsonschema import ValidationError

from ._convenience import info
from ._types import CustomType
from ._version import version as __version__
from .asdf import AsdfFile
from .asdf import open_asdf as open
from .config import config_context, get_config
from .exceptions import ValidationError
from .stream import Stream
from .tags.core import IntegerType
from .tags.core.external_reference import ExternalArrayReference
Expand Down
19 changes: 19 additions & 0 deletions asdf/_jsonschema/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2013 Julian Berman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
7 changes: 7 additions & 0 deletions asdf/_jsonschema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The files in this directory were originally cloned from

jsonschema 4.17.3

https://github.com/python-jsonschema/jsonschema/releases/tag/v4.17.3

See COPYING for use restrictions
55 changes: 55 additions & 0 deletions asdf/_jsonschema/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
An implementation of JSON Schema for Python
The main functionality is provided by the validator classes for each of the
supported JSON Schema versions.
Most commonly, `asdf._jsonschema.validators.validate` is the quickest way to simply
validate a given instance under a schema, and will create a validator
for you.
"""
import warnings

from asdf._jsonschema._format import FormatChecker
from asdf._jsonschema._types import TypeChecker
from asdf._jsonschema.exceptions import (
ErrorTree,
FormatError,
RefResolutionError,
SchemaError,
ValidationError,
)
from asdf._jsonschema.protocols import Validator
from asdf._jsonschema.validators import (
Draft3Validator,
Draft4Validator,
Draft6Validator,
Draft7Validator,
Draft201909Validator,
Draft202012Validator,
RefResolver,
validate,
)


def __getattr__(name):
format_checkers = {
"draft3_format_checker": Draft3Validator,
"draft4_format_checker": Draft4Validator,
"draft6_format_checker": Draft6Validator,
"draft7_format_checker": Draft7Validator,
"draft201909_format_checker": Draft201909Validator,
"draft202012_format_checker": Draft202012Validator,
}
ValidatorForFormat = format_checkers.get(name)
if ValidatorForFormat is not None:
warnings.warn(
f"Accessing asdf._jsonschema.{name} is deprecated and will be "
"removed in a future release. Instead, use the FORMAT_CHECKER "
"attribute on the corresponding Validator.",
DeprecationWarning,
stacklevel=2,
)
return ValidatorForFormat.FORMAT_CHECKER

raise AttributeError(f"module {__name__} has no attribute {name}")
Loading

0 comments on commit 14726b1

Please sign in to comment.