Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Sep 21, 2024
1 parent 9d3b7ca commit 5b1ecf4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 31 deletions.
39 changes: 20 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#* Variables
SHELL := /usr/bin/env bash
PYTHON := python
SHELL ?= /usr/bin/env bash
PYTHON ?= python
PYTHONPATH := `pwd`
POETRY ?= poetry

#* Poetry
.PHONY: poetry-install
Expand All @@ -14,36 +15,36 @@ poetry-remove:

.PHONY: poetry-plugins
poetry-plugins:
poetry self add poetry-plugin-up
$(POETRY) self add poetry-plugin-up

.PHONY: poetry-env
poetry-env:
poetry config virtualenvs.in-project true
$(POETRY) config virtualenvs.in-project true

.PHONY: publish
publish:
poetry publish --build
$(POETRY) publish --build

#* Installation
.PHONY: install
install: poetry-env
poetry lock -n && poetry export --without-hashes > requirements-lock.txt
poetry install -n
$(POETRY) lock -n && poetry export --without-hashes > requirements-lock.txt
$(POETRY) install -n
-poetry run mypy --install-types --non-interactive ./

.PHONY: install-dev
install-dev: poetry-env install
poetry install -n --with dev
$(POETRY) install -n --with dev

.PHONY: pre-commit-install
pre-commit-install:
poetry run pre-commit install
$(POETRY) run pre-commit install


#* Formatters
.PHONY: codestyle
codestyle:
poetry run ruff format --config=pyproject.toml stac_model tests
$(POETRY) run ruff format --config=pyproject.toml stac_model tests

.PHONY: format
format: codestyle
Expand All @@ -61,29 +62,29 @@ check-all: check

.PHONY: mypy
mypy:
poetry run mypy --config-file pyproject.toml ./
$(POETRY) run mypy --config-file pyproject.toml ./

.PHONY: check-mypy
check-mypy: mypy

.PHONY: check-safety
check-safety:
poetry check
poetry run safety check --full-report
poetry run bandit -ll --recursive stac_model tests
$(POETRY) check
$(POETRY) run safety check --full-report
$(POETRY) run bandit -ll --recursive stac_model tests

.PHONY: lint
lint:
poetry run ruff --config=pyproject.toml ./
poetry run pydocstyle --count --config=pyproject.toml ./
poetry run pydoclint --config=pyproject.toml ./
$(POETRY) run ruff --config=pyproject.toml ./
$(POETRY) run pydocstyle --count --config=pyproject.toml ./
$(POETRY) run pydoclint --config=pyproject.toml ./

.PHONY: check-lint
check-lint: lint

.PHONY: format-lint
format-lint:
poetry run ruff --config=pyproject.toml --fix ./
$(POETRY) run ruff --config=pyproject.toml --fix ./

.PHONY: install-npm
install-npm:
Expand Down Expand Up @@ -113,7 +114,7 @@ lint-all: lint mypy check-safety check-markdown

.PHONY: update-dev-deps
update-dev-deps:
poetry up --only=dev-dependencies --latest
$(POETRY) up --only=dev-dependencies --latest

#* Cleaning
.PHONY: pycache-remove
Expand Down
44 changes: 33 additions & 11 deletions json-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
{
"$comment": "This is the schema for STAC extension MLM in Items.",
"if": {
"required": ["type"],
"required": [
"type"
],
"properties": {
"type": {
"const": "Feature"
Expand Down Expand Up @@ -70,7 +72,9 @@
{
"$comment": "This is the schema for STAC extension MLM in Collections.",
"if": {
"required": ["type"],
"required": [
"type"
],
"properties": {
"type": {
"const": "Collection"
Expand Down Expand Up @@ -143,7 +147,9 @@
"$comment": "This is the JSON-object 'properties' definition, which describes the STAC-Item field named 'properties' containing 'eo:bands' as described in [https://github.com/stac-extensions/eo#item-properties-or-asset-fields].",
"properties": {
"properties": {
"required": ["eo:bands"],
"required": [
"eo:bands"
],
"properties": {
"eo:bands": {
"type": "array",
Expand All @@ -157,7 +163,9 @@
}
},
"stac_extensions_eo_bands_asset": {
"required": ["assets"],
"required": [
"assets"
],
"$comment": "This is the JSON-object 'properties' definition, which describes the STAC-Asset containing 'eo:bands' as described in [https://github.com/stac-extensions/eo#item-properties-or-asset-fields].",
"properties": {
"assets": {
Expand All @@ -166,7 +174,9 @@
"$ref": "#/$defs/AssetModelRole"
},
"then": {
"required": ["eo:bands"],
"required": [
"eo:bands"
],
"properties": {
"eo:bands": {
"type": "array",
Expand Down Expand Up @@ -197,7 +207,9 @@
}
},
"stac_extensions_raster_bands_asset": {
"required": ["assets"],
"required": [
"assets"
],
"$comment": "This is the JSON-object 'properties' definition, which describes the STAC-Item at least one Asset field containing 'raster:bands' as described in [https://github.com/stac-extensions/raster/tree/v1.1.0#item-asset-fields].",
"properties": {
"assets": {
Expand All @@ -216,7 +228,9 @@
"items": {
"$comment": "Raster extension does not explicitly indicate a 'name', but one is needed for MLM.",
"type": "object",
"required": ["name"],
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
Expand Down Expand Up @@ -408,7 +422,9 @@
"properties": {
"properties": {
"$comment": "This is the JSON-object 'properties' definition for the STAC MLM pretraining reference.",
"required": ["mlm:pretrained_source"],
"required": [
"mlm:pretrained_source"
],
"properties": {
"mlm:pretrained_source": {
"const": null
Expand Down Expand Up @@ -760,7 +776,9 @@
]
},
"AssetModelRole": {
"required": ["roles"],
"required": [
"roles"
],
"properties": {
"roles": {
"contains": {
Expand Down Expand Up @@ -802,8 +820,12 @@
}
},
"dependencies": {
"format": ["expression"],
"expression": ["format"]
"format": [
"expression"
],
"expression": [
"format"
]
},
"additionalProperties": false
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_mlm_missing_bands_invalid_if_mlm_input_lists_bands(

mlm_bands_bad_data = copy.deepcopy(mlm_example)
mlm_bands_bad_data["assets"]["weights"].pop("raster:bands") # type: ignore # no 'None' to raise in case modified
with pytest.raises(pystac.errors.STACValidationError) as err:
with pytest.raises(pystac.errors.STACValidationError):
mlm_bands_bad_item = pystac.Item.from_dict(mlm_bands_bad_data)
pystac.validation.validate(mlm_bands_bad_item, validator=mlm_validator)

Expand Down

0 comments on commit 5b1ecf4

Please sign in to comment.