From 873e3d0a26f9d21f8dfb9fc8387681510906e339 Mon Sep 17 00:00:00 2001 From: Pierrick Rambaud Date: Mon, 9 Dec 2024 07:32:42 +0000 Subject: [PATCH] build: fix linting error --- .copier-answers.yml | 7 +- .devcontainer/devcontainer.json | 14 ++-- .github/workflows/pypackage_check.yaml | 1 - .pre-commit-config.yaml | 1 - docs/_static/custom-icon.js | 4 +- noxfile.py | 3 + pygaul/__init__.py | 2 +- pyproject.toml | 8 +- tests/check_warnings.py | 1 - warnings.txt | 109 +++++++++++++++++++++++++ 10 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 warnings.txt diff --git a/.copier-answers.yml b/.copier-answers.yml index 09c7730..4145ca5 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -5,10 +5,11 @@ author_email: pierrick.rambaud49@gmail.com author_first_name: Pierrick author_last_name: Rambaud author_orcid: 0000-0001-8764-5749 -creation_year: '2023' +creation_year: "2023" github_repo_name: pygaul github_user: gee-community project_name: pyGAUL project_slug: pygaul -short_description: Easy access to administrative boundary defined by FAO GAUL from - Python scripts +short_description: + Easy access to administrative boundary defined by FAO GAUL from + Python scripts diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8ae70b7..0288d0c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,9 @@ { - "name": "Python 3", - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/devcontainers-contrib/features/nox:2": {}, - "ghcr.io/devcontainers-contrib/features/pre-commit:2": {} - }, - "postCreateCommand": "python -m pip install commitizen uv && pre-commit install" + "name": "Python 3", + "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", + "features": { + "ghcr.io/devcontainers-contrib/features/nox:2": {}, + "ghcr.io/devcontainers-contrib/features/pre-commit:2": {} + }, + "postCreateCommand": "python -m pip install commitizen uv && pre-commit install" } diff --git a/.github/workflows/pypackage_check.yaml b/.github/workflows/pypackage_check.yaml index 8b38f32..d9dd589 100644 --- a/.github/workflows/pypackage_check.yaml +++ b/.github/workflows/pypackage_check.yaml @@ -51,4 +51,3 @@ jobs: > You may need to reinstall ``copier`` and ``jinja2-time`` if they are not available in your environment. After solving the merging issues you can push back the changes to your main branch. - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a4b1fc..c4a21ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,4 +49,3 @@ repos: - id: check-merge-conflict stages: [pre-commit] args: [--assume-in-merge] - diff --git a/docs/_static/custom-icon.js b/docs/_static/custom-icon.js index 0475374..d947d8a 100644 --- a/docs/_static/custom-icon.js +++ b/docs/_static/custom-icon.js @@ -12,5 +12,5 @@ FontAwesome.library.add( "e001", // unicode codepoint - private use area "M12.045.033a12.181 12.182 0 00-1.361.078 17.512 17.513 0 011.813 1.433l.48.438-.465.45a15.047 15.048 0 00-1.126 1.205l-.178.215a8.527 8.527 0 01.86-.05 8.154 8.155 0 11-4.286 15.149 15.764 15.765 0 01-1.841.106h-.86a21.847 21.848 0 00.264 2.866 11.966 11.967 0 106.7-21.89zM8.17.678a12.181 12.182 0 00-2.624 1.275 15.506 15.507 0 011.813.43A18.551 18.552 0 018.17.678zM9.423.75a16.237 16.238 0 00-.995 1.998 16.15 16.152 0 011.605.66 6.98 6.98 0 01.43-.509c.234-.286.472-.559.716-.817A15.047 15.048 0 009.423.75zM4.68 2.949a14.969 14.97 0 000 2.336c.587-.065 1.196-.1 1.812-.107a16.617 16.617 0 01.48-1.748 16.48 16.481 0 00-2.292-.481zM3.62 3.5A11.938 11.938 0 001.762 5.88a17.004 17.004 0 011.877-.444A17.39 17.391 0 013.62 3.5zm4.406.287c-.143.437-.265.888-.38 1.347a8.255 8.255 0 011.67-.803c-.423-.2-.845-.38-1.29-.544zM6.3 6.216a14.051 14.052 0 00-1.555.108c.064.523.157 1.038.272 1.554a8.39 8.391 0 011.283-1.662zm-2.55.137a15.313 15.313 0 00-2.602.716h-.078v.079a17.104 17.105 0 001.267 2.544l.043.071.072-.049a16.309 16.31 0 011.734-1.083l.057-.035V8.54a16.867 16.868 0 01-.408-2.094v-.092zM.644 8.095l-.063.2A11.844 11.845 0 000 11.655v.209l.143-.152a17.706 17.707 0 011.584-1.447l.057-.043-.043-.064a16.18 16.18 0 01-1.025-1.87zm3.77 1.253l-.18.1c-.465.273-.93.573-1.375.889l-.065.05.05.064c.309.437.645.867.996 1.276l.137.165v-.208a8.176 8.176 0 01.364-2.15zM2.2 10.853l-.072.05a16.574 16.574 0 00-1.813 1.734l-.058.058.066.057a15.449 15.45 0 001.991 1.483l.072.05.043-.08a16.738 16.74 0 011.053-1.64v-.05l-.043-.05a16.99 16.99 0 01-1.19-1.54zm1.855 2.071l-.121.172a15.363 15.363 0 00-.917 1.433l-.043.072.071.043a16.61 16.61 0 001.562.766l.193.086-.086-.193a8.04 8.04 0 01-.66-2.172zm-3.976.48v.2a11.758 11.759 0 00.946 3.326l.078.186.072-.194a16.215 16.216 0 01.845-2l.057-.063-.064-.043a17.197 17.198 0 01-1.776-1.284zm2.543 1.805l-.035.08a15.764 15.765 0 00-.983 2.479v.08h.086a16.15 16.152 0 002.688.5l.072.007v-.086a17.562 17.563 0 01.164-2.056v-.065H4.55a16.266 16.266 0 01-1.849-.896zm2.544 1.169v.114a17.254 17.255 0 00-.151 1.828v.078h.931c.287 0 .624.014.946 0h.209l-.166-.129a8.011 8.011 0 01-1.64-1.834zm-3.29 2.1l.115.172a11.988 11.988 0 002.502 2.737l.157.129v-.201a22.578 22.58 0 01-.2-2.336v-.071h-.072a16.23 16.23 0 01-2.3-.387z", // svg path (https://simpleicons.org/icons/anaconda.svg) ], - }) -); \ No newline at end of file + }), +); diff --git a/noxfile.py b/noxfile.py index ee0297b..bd34785 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,7 @@ The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder. """ + import datetime import fileinput @@ -9,6 +10,7 @@ nox.options.sessions = ["lint", "test", "docs", "mypy"] + @nox.session(reuse_venv=True, venv_backend="uv") def lint(session): """Apply the pre-commits.""" @@ -23,6 +25,7 @@ def test(session): test_files = session.posargs or ["tests"] session.run("pytest", "--cov", "--cov-report=html", *test_files) + @nox.session(reuse_venv=True, name="ci-test", venv_backend="uv") def ci_test(session): """Run all the test and report coverage in xml.""" diff --git a/pygaul/__init__.py b/pygaul/__init__.py index bb42d12..6c25b83 100644 --- a/pygaul/__init__.py +++ b/pygaul/__init__.py @@ -15,7 +15,7 @@ import ee import numpy as np import pandas as pd -from deprecated.sphinx import deprecated, versionadded +from deprecated.sphinx import deprecated, versionadded # type: ignore [import-untyped] __version__ = "0.3.4" __author__ = "Pierrick Rambaud" diff --git a/pyproject.toml b/pyproject.toml index 4435266..a487012 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,8 +90,10 @@ testpaths = "tests" [tool.ruff] line-length = 100 -ignore-init-module-imports = true fix = true + + +[tool.ruff.lint] select = ["E", "F", "W", "I", "D", "RUF"] ignore = [ "E501", # line too long | Black take care of it @@ -99,10 +101,10 @@ ignore = [ "D101", # Missing docstring in public class | We use D106 ] -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] docstring-quotes = "double" -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" [tool.coverage.run] diff --git a/tests/check_warnings.py b/tests/check_warnings.py index 73750c8..04db76e 100644 --- a/tests/check_warnings.py +++ b/tests/check_warnings.py @@ -52,7 +52,6 @@ def check_warnings(file: Path) -> int: if __name__ == "__main__": - # cast the file to path and resolve to an absolute one file = Path.cwd() / "warnings.txt" diff --git a/warnings.txt b/warnings.txt new file mode 100644 index 0000000..fbcd0b4 --- /dev/null +++ b/warnings.txt @@ -0,0 +1,109 @@ + +Traceback (most recent call last): + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/cmd/build.py", line 285, in build_main + app.build(args.force_all, args.filenames) + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/application.py", line 353, in build + self.builder.build_update() + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 311, in build_update + self.build(to_build, + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 328, in build + updated_docnames = set(self.read()) + ^^^^^^^^^^^ + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 435, in read + self._read_serial(docnames) + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 456, in _read_serial + self.read_doc(docname) + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 512, in read_doc + publisher.publish() + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/docutils/core.py", line 226, in publish + self.apply_transforms() + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/docutils/core.py", line 206, in apply_transforms + self.document.transformer.apply_transforms() + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/sphinx/transforms/__init__.py", line 79, in apply_transforms + super().apply_transforms() + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/docutils/transforms/__init__.py", line 173, in apply_transforms + transform.apply(**kwargs) + File "/home/rambap/github/pygaul/.nox/docs/lib/python3.12/site-packages/jupyter_sphinx/execute.py", line 170, in apply + raise ExtensionError( +sphinx.errors.ExtensionError: Cell raised uncaught exception: +--------------------------------------------------------------------------- +ModuleNotFoundError Traceback (most recent call last) +Cell In[1], line 2 + 1 import pygaul +----> 2 from geemap import Map + 3 import ee + 5 ee.Initialize() + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/__init__.py:55 + 51 else: + 52 print( + 53 "Please restart Jupyter kernel after installation if you encounter any errors when importing geemap." + 54 ) +---> 55 raise e + 57 if _use_eerepr(): + 58 import eerepr + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/__init__.py:45 + 43 else: + 44 try: +---> 45 from .geemap import * + 46 except Exception as e: + 47 if in_colab_shell(): + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/geemap.py:28 + 26 from .basemaps import get_xyz_dict, xyz_to_leaflet + 27 from .common import * +---> 28 from .conversion import * + 29 from .ee_tile_layers import * + 30 from . import core + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/conversion.py:23 + 20 from collections import deque + 21 from pathlib import Path +---> 23 import pkg_resources + 25 from .common import * + 28 def find_matching_bracket(lines, start_line_index, start_char_index, matching_char="{"): + +ModuleNotFoundError: No module named 'pkg_resources' + +Extension error: +Cell raised uncaught exception: +--------------------------------------------------------------------------- +ModuleNotFoundError Traceback (most recent call last) +Cell In[1], line 2 + 1 import pygaul +----> 2 from geemap import Map + 3 import ee + 5 ee.Initialize() + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/__init__.py:55 + 51 else: + 52 print( + 53 "Please restart Jupyter kernel after installation if you encounter any errors when importing geemap." + 54 ) +---> 55 raise e + 57 if _use_eerepr(): + 58 import eerepr + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/__init__.py:45 + 43 else: + 44 try: +---> 45 from .geemap import * + 46 except Exception as e: + 47 if in_colab_shell(): + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/geemap.py:28 + 26 from .basemaps import get_xyz_dict, xyz_to_leaflet + 27 from .common import * +---> 28 from .conversion import * + 29 from .ee_tile_layers import * + 30 from . import core + +File ~/github/pygaul/.nox/docs/lib/python3.12/site-packages/geemap/conversion.py:23 + 20 from collections import deque + 21 from pathlib import Path +---> 23 import pkg_resources + 25 from .common import * + 28 def find_matching_bracket(lines, start_line_index, start_char_index, matching_char="{"): + +ModuleNotFoundError: No module named 'pkg_resources'