Skip to content

Commit 66547c0

Browse files
authored
Merge pull request #228 from stac-utils/update-3.8
v3.3.2
2 parents 3460d07 + b4909b9 commit 66547c0

File tree

10 files changed

+40
-24
lines changed

10 files changed

+40
-24
lines changed

.github/workflows/test-runner.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
21+
python-version: ["3.8", "3.9", "3.10", "3.11"]
2222

2323
steps:
2424

CHANGELOG.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
66

77
## [Unreleased]
88

9+
## [v3.3.2] - 2023-11-17
10+
911
### Added
1012

11-
- Docstrings https://github.com/stac-utils/stac-validator/pull/224
13+
- Docstrings ([#224](https://github.com/stac-utils/stac-validator/pull/224))
14+
15+
### Changed
16+
17+
- Development dependencies removed from runtime dependency list
18+
([#228](https://github.com/stac-utils/stac-check/pull/109))
19+
- Remove jsonschema RefResolver ([#228](https://github.com/stac-utils/stac-check/pull/109))
1220

1321
## [v3.3.1] - 2022-12-16
1422

@@ -183,7 +191,8 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
183191
- With the newest version - 1.0.0-beta.2 - items will run through jsonchema validation before the PySTAC validation. The reason for this is that jsonschema will give more informative error messages. This should be addressed better in the future. This is not the case with the --recursive option as time can be a concern here with larger collections.
184192
- Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections.
185193

186-
[Unreleased]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.1..main>
194+
[Unreleased]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.2..main>
195+
[v3.3.2]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.1..v3.3.2>
187196
[v3.3.1]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.0..v3.3.1>
188197
[v3.3.0]: <https://github.com/sparkgeo/stac-validator/compare/v3.2.0..v3.3.0>
189198
[v3.2.0]: <https://github.com/sparkgeo/stac-validator/compare/v3.1.0..v3.2.0>

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ Installation from Repo
5555
pip install .
5656
```
5757

58-
or (for development)
58+
or for local development
5959

6060
```bash
61-
pip install --editable .["test"]
61+
pip install -e '.[dev]'
6262
```
6363

64+
6465
The [Makefile](./Makefile) has convenience commands if Make is installed.
6566

6667
```bash

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ black
22
pytest
33
pytest-mypy
44
pre-commit
5+
types-jsonschema

setup.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22

33
from setuptools import setup
44

5-
__version__ = "3.3.1"
5+
__version__ = "3.3.2"
66

77
with open("README.md", "r") as fh:
88
long_description = fh.read()
99

10-
extra_reqs = {
11-
"test": ["pytest"],
12-
}
13-
1410
setup(
1511
name="stac_validator",
1612
version=__version__,
@@ -29,17 +25,21 @@
2925
long_description=long_description,
3026
long_description_content_type="text/markdown",
3127
url="https://github.com/stac-utils/stac-validator",
32-
download_url="https://github.com/stac-utils/stac-validator/archive/v2.5.0.tar.gz",
3328
install_requires=[
3429
"requests>=2.19.1",
3530
"jsonschema>=3.2.0",
3631
"click>=8.0.0",
37-
"types-setuptools",
3832
],
33+
extras_require={
34+
"dev": [
35+
"pytest",
36+
"types-setuptools",
37+
],
38+
},
3939
packages=["stac_validator"],
4040
entry_points={
4141
"console_scripts": ["stac-validator = stac_validator.stac_validator:main"]
4242
},
43-
python_requires=">=3.7",
43+
python_requires=">=3.8",
4444
tests_require=["pytest"],
4545
)

stac_validator/stac_validator.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Any, Dict, List
44

55
import click # type: ignore
6-
import pkg_resources
76

87
from .validate import StacValidate
98

@@ -101,7 +100,6 @@ def item_collection_summary(message: List[Dict[str, Any]]) -> None:
101100
default="",
102101
help="Save full recursive output to log file (local filepath).",
103102
)
104-
@click.version_option(version=pkg_resources.require("stac-validator")[0].version)
105103
def main(
106104
stac_file: str,
107105
item_collection: bool,

stac_validator/validate.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import click # type: ignore
88
import jsonschema # type: ignore
9-
from jsonschema import RefResolver
9+
from jsonschema.validators import validator_for
1010
from requests import exceptions # type: ignore
1111

1212
from .utilities import (
@@ -216,12 +216,13 @@ def custom_validator(self) -> None:
216216
jsonschema.validate(self.stac_content, schema)
217217
# in case the path to a json schema is local
218218
elif os.path.exists(self.schema):
219-
schema = fetch_and_parse_schema(self.schema)
220-
custom_abspath = os.path.abspath(self.schema)
221-
custom_dir = os.path.dirname(custom_abspath).replace("\\", "/")
222-
custom_uri = f"file:///{custom_dir}/"
223-
resolver = RefResolver(custom_uri, self.schema)
224-
jsonschema.validate(self.stac_content, schema, resolver=resolver)
219+
schema_dict = fetch_and_parse_schema(self.schema)
220+
# determine the appropriate validator class for the schema
221+
ValidatorClass = validator_for(schema_dict)
222+
validator = ValidatorClass(schema_dict)
223+
# validate the content
224+
validator.validate(self.stac_content)
225+
225226
# deal with a relative path in the schema
226227
else:
227228
file_directory = os.path.dirname(os.path.abspath(str(self.stac_file)))

tests/test_default.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
44
"""
55

6+
import pytest
7+
68
from stac_validator import stac_validator
79

810

@@ -22,6 +24,7 @@ def test_default_v070():
2224
]
2325

2426

27+
@pytest.mark.skip(reason="staclint eo extension schema invalid")
2528
def test_default_item_local_v080():
2629
stac_file = "tests/test_data/v080/items/sample-full.json"
2730
stac = stac_validator.StacValidate(stac_file)

tests/test_extensions.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
44
"""
55

6+
import pytest
7+
68
from stac_validator import stac_validator
79

810

11+
@pytest.mark.skip(reason="staclint eo extension schema invalid")
912
def test_item_local_v080():
1013
stac_file = "tests/test_data/v080/items/sample-full.json"
1114
stac = stac_validator.StacValidate(stac_file, extensions=True)

tests/test_links.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ def test_item_v100():
6868
"http://remotedata.io/catalog/20201211_223832_CS2/index.html",
6969
],
7070
"format_invalid": [],
71-
"request_valid": [
71+
"request_valid": [],
72+
"request_invalid": [
7273
"http://remotedata.io/collection.json",
7374
"http://remotedata.io/collection.json",
7475
"http://remotedata.io/collection.json",
7576
"http://remotedata.io/catalog/20201211_223832_CS2/index.html",
7677
],
77-
"request_invalid": [],
7878
},
7979
}
8080
]

0 commit comments

Comments
 (0)