diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 870215d..444794b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,11 +21,11 @@ jobs: run: | sudo apt-get update && sudo apt-get install libsndfile1 python -m pip install --upgrade pip - python -m pip install pytest hypothesis ruff mypy black html5lib + python -m pip install pytest hypothesis ruff pyright html5lib python -m pip install ".[all]" - name: Make sure types are consistent - run: mypy --ignore-missing-imports src + run: pyright src - name: Lint with ruff - run: ruff src + run: ruff check src - name: Test with pytest run: pytest tests diff --git a/Makefile b/Makefile index 81c22a6..eb00387 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,17 @@ fmt: ## Format code using black & isort. $(ENV_PREFIX)ruff format $(PROJECT_NAME)/ $(ENV_PREFIX)ruff format tests/ -.PHONY: lint -lint: ## Run ruff, black, mypy linters. +.PHONY: lint-mypy +lint-pyright: + $(ENV_PREFIX)pyright $(PROJECT_NAME)/ + +.PHONY: lint-ruff +lint-ruff: $(ENV_PREFIX)ruff check $(PROJECT_NAME)/ $(ENV_PREFIX)ruff check tests/ - $(ENV_PREFIX)mypy $(PROJECT_NAME)/ --config-file pyproject.toml + +.PHONY: lint +lint: lint-mypy lint-ruff .PHONY: test-watch test-watch: ## Run tests and generate coverage report. diff --git a/pyproject.toml b/pyproject.toml index 9d0772d..81d49aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,8 +41,6 @@ rye = { dev-dependencies = [ "icecream>=2.1.3", "pytest>=7.4.0", "coverage[toml]>=7.3.2", - "black>=23.3.0", - "mypy>=1.4.1", "pytest-coverage>=0.0", "mkdocs>=1.2.4", "importlib-metadata>=4.3", @@ -57,6 +55,7 @@ rye = { dev-dependencies = [ "pytest-watch>=4.2.0", "pytest-testmon>=2.0.12", "html5lib>=1.1", + "pyright>=1.1.362", ] } [tool.pytest.ini_options] diff --git a/requirements-dev.lock b/requirements-dev.lock index 42a3053..161a14f 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -23,7 +23,6 @@ babel==2.14.0 # via mkdocs-material birdsong-recognition-dataset==0.3.2.post1 # via crowsetta -black==24.4.2 cachetools==5.3.3 # via tox certifi==2024.2.2 @@ -35,7 +34,6 @@ chardet==5.2.0 charset-normalizer==3.3.2 # via requests click==8.1.7 - # via black # via mkdocs # via mkdocstrings colorama==0.4.6 @@ -143,11 +141,10 @@ mkdocstrings-python==1.10.0 # via mkdocstrings multimethod==1.10 # via pandera -mypy==1.10.0 mypy-extensions==1.0.0 - # via black - # via mypy # via typing-inspect +nodeenv==1.8.0 + # via pyright numpy==1.24.4 # via birdsong-recognition-dataset # via contourpy @@ -161,7 +158,6 @@ numpy==1.24.4 # via shapely # via xarray packaging==24.0 - # via black # via matplotlib # via mkdocs # via mkdocs-gallery @@ -179,12 +175,10 @@ pandas==2.0.3 pandera==0.18.3 # via crowsetta pathspec==0.12.1 - # via black # via mkdocs pillow==10.3.0 # via matplotlib platformdirs==4.2.1 - # via black # via mkdocs-get-deps # via mkdocstrings # via tox @@ -211,6 +205,7 @@ pyparsing==3.1.2 # via matplotlib pyproject-api==1.6.1 # via tox +pyright==1.1.362 pytest==8.1.2 # via pytest-cov # via pytest-testmon @@ -248,6 +243,8 @@ scipy==1.10.1 # via evfuncs # via scikit-learn # via soundevent +setuptools==69.5.1 + # via nodeenv shapely==2.0.4 # via soundevent six==1.16.0 @@ -263,9 +260,7 @@ soundfile==0.12.1 threadpoolctl==3.4.0 # via scikit-learn tomli==2.0.1 - # via black # via coverage - # via mypy # via pyproject-api # via pytest # via tox @@ -276,9 +271,7 @@ typeguard==4.2.1 # via pandera typing-extensions==4.11.0 # via annotated-types - # via black # via mkdocstrings - # via mypy # via pydantic # via pydantic-core # via typeguard diff --git a/src/soundevent/data/geometries.py b/src/soundevent/data/geometries.py index a83a718..83d6a54 100644 --- a/src/soundevent/data/geometries.py +++ b/src/soundevent/data/geometries.py @@ -908,7 +908,7 @@ def geometry_validate( if not hasattr(obj, "type"): raise ValueError(f"Object {obj} does not have a type attribute.") - geom_type = obj.type + geom_type = obj.type # type: ignore if geom_type not in GEOMETRY_MAPPING: raise ValueError(f"Object {obj} does not have a geometry valid type.") diff --git a/src/soundevent/io/crowsetta/labels.py b/src/soundevent/io/crowsetta/labels.py index 546d3a5..03ca830 100644 --- a/src/soundevent/io/crowsetta/labels.py +++ b/src/soundevent/io/crowsetta/labels.py @@ -23,7 +23,7 @@ LabelToTagFn = Callable[[str], Union[List[data.Tag], data.Tag]] -LabelToTagMap = dict[str, Union[List[data.Tag], data.Tag]] +LabelToTagMap = Dict[str, Union[List[data.Tag], data.Tag]] def label_to_tags( @@ -110,7 +110,7 @@ def label_to_tags( def label_from_tag( tag: data.Tag, label_fn: Optional[Callable[[data.Tag], str]] = None, - label_mapping: Optional[dict[data.Tag, str]] = None, + label_mapping: Optional[Dict[data.Tag, str]] = None, value_only: bool = False, separator: str = ":", ) -> str: