From 7f7620c1f3c5808d20485d8afe0657b8c5e7f5c1 Mon Sep 17 00:00:00 2001 From: Francis Charette-Migneault Date: Wed, 17 Apr 2024 23:51:43 -0400 Subject: [PATCH] more linting fixes --- .github/workflows/build.yml | 8 ++------ .github/workflows/test.yaml | 2 +- Makefile | 2 +- README.md | 2 +- pyproject.toml | 16 ++++++++++++---- stac_model/__init__.py | 4 +++- stac_model/schema.py | 34 ++++++++++++++++++++++++---------- 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fe8d65..250a7a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,14 +29,10 @@ jobs: - name: Install dependencies run: make install-dev - - name: Run style checks + - name: Run checks run: | - make lint + make lint-all - name: Run tests run: | make test - - - name: Run safety checks - run: | - make check-safety diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 87f33a5..d44317b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,4 +11,4 @@ jobs: - uses: actions/checkout@v2 - run: | npm install - npm test \ No newline at end of file + npm test diff --git a/Makefile b/Makefile index e7bc0dd..3dd26e5 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ format-examples: install-npm fix-%: format-%s .PHONY: lint-all -lint: test lint mypy check-safety check-markdown +lint-all: lint mypy check-safety check-markdown .PHONY: update-dev-deps update-dev-deps: diff --git a/README.md b/README.md index 9a0f58f..07261ea 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ connectors, please refer to the [STAC Model](README_STAC_MODEL.md) document. > FIXME: update examples - Examples: - - [Example with a ??? trained with torchgeo](examples/item.json) TODO update example + - **Example with a ??? trained with torchgeo** :warning: TODO update example - [Collection example](examples/collection.json): Shows the basic usage of the extension in a STAC Collection - [JSON Schema](json-schema/schema.json) TODO update - [Changelog](./CHANGELOG.md) diff --git a/pyproject.toml b/pyproject.toml index 91adf41..05160d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,7 +96,8 @@ exclude = [ "build", "dist", "env", - "venv" + "venv", + "node_modules", ] respect-gitignore = true line-length = 120 @@ -159,7 +160,9 @@ warn_required_dynamic_aliases = true # https://github.com/PyCQA/pydocstyle # http://www.pydocstyle.org/en/stable/usage.html#available-options convention = "google" - +match_dir = "^(stac_model|tests)" +# ignore missing documentation, just validate provided ones +add_ignore = "D100,D101,D102,D103,D104,D105,D107,D200,D202,D204,D212,D401" [tool.pydoclint] # https://github.com/jsh9/pydoclint @@ -179,9 +182,13 @@ exclude = ''' | dist | env | venv + | node_modules )/ ''' - +# don't require type hints, since we have them in the signature instead (don't duplicate) +arg-type-hints-in-docstring = false +arg-type-hints-in-signature = true +check-return-types = false [tool.pytest.ini_options] # https://github.com/pytest-dev/pytest @@ -196,7 +203,8 @@ norecursedirs =[ "docs", ".tox", ".git", - "__pycache__" + "__pycache__", + "node_modules", ] doctest_optionflags = ["NUMBER", "NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL"] timeout = 1000 diff --git a/stac_model/__init__.py b/stac_model/__init__.py index 5ed00f2..cb1e8e2 100644 --- a/stac_model/__init__.py +++ b/stac_model/__init__.py @@ -1,4 +1,6 @@ -"""A PydanticV2 validation and serialization library for the STAC ML Model Extension""" +""" +A PydanticV2/PySTAC validation and serialization library for the STAC Machine Learning Model Extension. +""" from importlib import metadata diff --git a/stac_model/schema.py b/stac_model/schema.py index a8db2b1..38c35fc 100644 --- a/stac_model/schema.py +++ b/stac_model/schema.py @@ -82,8 +82,8 @@ def apply( self, properties: Union[MLModelProperties, dict[str, Any]], ) -> None: - """Applies Machine Learning Model Extension properties to the extended - :class:`~pystac.Item` or :class:`~pystac.Asset`. + """ + Applies Machine Learning Model Extension properties to the extended :mod:`~pystac` object. """ if isinstance(properties, dict): properties = MLModelProperties(**properties) @@ -122,14 +122,19 @@ def ext( "ItemMLModelExtension", "AssetMLModelExtension", ]: - """Extends the given STAC Object with properties from the - :stac-ext:`Machine Learning Model Extension `. + """ + Extends the given STAC Object with properties from the :stac-ext:`Machine Learning Model Extension `. - This extension can be applied to instances of :class:`~pystac.Item` or - :class:`~pystac.Asset`. + This extension can be applied to instances of :class:`~pystac.Item` or :class:`~pystac.Asset`. - Raises: + Args: + obj: STAC Object to extend with the MLM extension fields. + add_if_missing: Add the MLM extension schema URI to the object if not already in `stac_extensions`. + Returns: + Extended object. + + Raises: pystac.ExtensionTypeError : If an invalid object type is passed. """ if isinstance(obj, pystac.Collection): @@ -155,7 +160,10 @@ def summaries(cls, obj: pystac.Collection, add_if_missing: bool = False) -> "Sum class SummariesMLModelExtension(SummariesExtension): - """A concrete implementation of :class:`~SummariesExtension` that extends + """ + Summaries annotated with the Machine Learning Model Extension. + + A concrete implementation of :class:`~SummariesExtension` that extends the ``summaries`` field of a :class:`~pystac.Collection` to include properties defined in the :stac-ext:`Machine Learning Model `. """ @@ -192,7 +200,10 @@ def __setattr__(self, prop, value): class ItemMLModelExtension(MLModelExtension[pystac.Item]): - """A concrete implementation of :class:`MLModelExtension` on an + """ + Item annotated with the Machine Learning Model Extension. + + A concrete implementation of :class:`MLModelExtension` on an :class:`~pystac.Item` that extends the properties of the Item to include properties defined in the :stac-ext:`Machine Learning Model Extension `. @@ -219,7 +230,10 @@ def __repr__(self) -> str: class AssetMLModelExtension(MLModelExtension[pystac.Asset]): - """A concrete implementation of :class:`MLModelExtension` on an + """ + Asset annotated with the Machine Learning Model Extension. + + A concrete implementation of :class:`MLModelExtension` on an :class:`~pystac.Asset` that extends the Asset fields to include properties defined in the :stac-ext:`Machine Learning Model Extension `.