diff --git a/.copier-answers.yml b/.copier-answers.yml index 332d465..5b99b37 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: 0.1.11 +_commit: 0.1.16 _src_path: gh:12rambau/pypackage author_email: pierrick.rambaud49@gmai.com author_first_name: Pierrick diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index af9f107..0288d0c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,5 +5,5 @@ "ghcr.io/devcontainers-contrib/features/nox:2": {}, "ghcr.io/devcontainers-contrib/features/pre-commit:2": {} }, - "postCreateCommand": "python -m pip install commitizen && pre-commit install" + "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 648f1a6..d9dd589 100644 --- a/.github/workflows/pypackage_check.yaml +++ b/.github/workflows/pypackage_check.yaml @@ -2,15 +2,16 @@ name: template update check on: workflow_dispatch: - schedule: - - cron: "0 0 1 * *" # Run at 00:00 on the first day of each month + +env: + PIP_ROOT_USER_ACTION: ignore jobs: check_version: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.10" - name: install dependencies diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6136dfd..75830dd 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,6 +4,9 @@ on: release: types: [created] +env: + PIP_ROOT_USER_ACTION: ignore + jobs: tests: uses: ./.github/workflows/unit.yaml @@ -12,12 +15,12 @@ jobs: needs: [tests] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.11" - name: Install dependencies - run: pip install twine build nox + run: pip install twine build nox[uv] - name: update citation date run: nox -s release-date - name: Build and publish diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml index af6c243..5bc1935 100644 --- a/.github/workflows/unit.yaml +++ b/.github/workflows/unit.yaml @@ -7,25 +7,29 @@ on: - main pull_request: +env: + FORCE_COLOR: 1 + PIP_ROOT_USER_ACTION: ignore + jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.11" - uses: pre-commit/action@v3.0.0 mypy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.11" - name: Install nox - run: pip install nox + run: pip install nox[uv] - name: run mypy checks run: nox -s mypy @@ -33,12 +37,12 @@ jobs: needs: [lint, mypy] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.11" - name: Install nox - run: pip install nox + run: pip install nox[uv] - name: build static docs run: nox -s docs @@ -56,13 +60,13 @@ jobs: python-version: "3.11" runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install nox - run: pip install nox + run: pip install nox[uv] - name: test with pytest run: nox -s ci-test - name: assess dead fixtures @@ -84,7 +88,7 @@ jobs: name: coverage path: coverage.xml - name: codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: file: ./coverage.xml token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67a3941..c4a21ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,6 @@ default_install_hook_types: [pre-commit, commit-msg] repos: - - repo: "https://github.com/psf/black" - rev: "22.3.0" - hooks: - - id: black - stages: [commit] - - repo: "https://github.com/commitizen-tools/commitizen" rev: "v2.18.0" hooks: @@ -17,38 +11,34 @@ repos: rev: "0.5.0" hooks: - id: nbstripout - stages: [commit] + stages: [pre-commit] - - repo: "https://github.com/pre-commit/mirrors-prettier" - rev: "v2.7.1" + - repo: "https://github.com/pycontribs/mirrors-prettier" + rev: "v3.4.2" hooks: - id: prettier - stages: [commit] + stages: [pre-commit] exclude: tests\/test_.+\. - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.0.215" + rev: "v0.7.0" hooks: - id: ruff - stages: [commit] - - - repo: https://github.com/PyCQA/doc8 - rev: "v1.1.1" - hooks: - - id: doc8 - stages: [commit] + stages: [pre-commit] + - id: ruff-format + stages: [pre-commit] - - repo: https://github.com/FHPythonUtils/LicenseCheck - rev: "2023.5.1" + - repo: https://github.com/sphinx-contrib/sphinx-lint + rev: "v1.0.0" hooks: - - id: licensecheck - stages: [commit] + - id: sphinx-lint + stages: [pre-commit] - repo: https://github.com/codespell-project/codespell rev: v2.2.4 hooks: - id: codespell - stages: [commit] + stages: [pre-commit] additional_dependencies: - tomli @@ -57,5 +47,5 @@ repos: rev: v4.3.0 hooks: - id: check-merge-conflict - stages: [commit] + stages: [pre-commit] args: [--assume-in-merge] diff --git a/README.rst b/README.rst index f5861c2..b987b57 100644 --- a/README.rst +++ b/README.rst @@ -1,46 +1,48 @@ PyGADM ====== -.. image:: https://img.shields.io/badge/License-MIT-yellow?logo=opensourceinitiative&logoColor=white +.. |license| image:: https://img.shields.io/badge/License-MIT-yellow.svg?logo=opensourceinitiative&logoColor=white :target: LICENSE :alt: License: MIT -.. image:: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow?logo=git&logoColor=white +.. |commit| image:: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?logo=git&logoColor=white :target: https://conventionalcommits.org :alt: conventional commit -.. image:: https://img.shields.io/badge/code%20style-black-000000?logo=ford&logoColor=white - :target: https://github.com/psf/black - :alt: Black badge +.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json + :target: https://github.com/astral-sh/ruff + :alt: ruff badge -.. image:: https://img.shields.io/badge/code_style-prettier-ff69b4?logo=prettier&logoColor=white +.. |prettier| image:: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier&logoColor=white :target: https://github.com/prettier/prettier :alt: prettier badge -.. image:: https://img.shields.io/badge/pre--commit-active-yellow?logo=pre-commit&logoColor=white +.. |pre-commmit| image:: https://img.shields.io/badge/pre--commit-active-yellow?logo=pre-commit&logoColor=white :target: https://pre-commit.com/ :alt: pre-commit -.. image:: https://img.shields.io/pypi/v/pygadm?color=blue&logo=python&logoColor=white +.. |pypi| image:: https://img.shields.io/pypi/v/pygadm?color=blue&logo=pypi&logoColor=white :target: https://pypi.org/project/pygadm/ :alt: PyPI version -.. image:: https://img.shields.io/conda/vn/conda-forge/pygadm?color=blue&logo=anaconda&logoColor=white +.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/pygadm?color=blue&logo=anaconda&logoColor=white :target: https://anaconda.org/conda-forge/pygadm :alt: Conda Version -.. image:: https://img.shields.io/github/actions/workflow/status/12rambau/pygadm/unit.yaml?logo=github&logoColor=white +.. |build| image:: https://img.shields.io/github/actions/workflow/status/12rambau/pygadm/unit.yaml?logo=github&logoColor=white :target: https://github.com/12rambau/pygadm/actions/workflows/unit.yaml :alt: build -.. image:: https://img.shields.io/codecov/c/github/12rambau/pygadm?logo=codecov&logoColor=white +.. |coverage| image:: https://img.shields.io/codecov/c/github/12rambau/pygadm?logo=codecov&logoColor=white :target: https://codecov.io/gh/12rambau/pygadm :alt: Test Coverage -.. image:: https://img.shields.io/readthedocs/pygadm?logo=readthedocs&logoColor=white +.. |docs| image:: https://img.shields.io/readthedocs/pygadm?logo=readthedocs&logoColor=white :target: https://pygadm.readthedocs.io/en/latest/ :alt: Documentation Status +|license| |commit| |ruff| |prettier| |pre-commmit| |pypi| |conda| |build| |coverage| |docs| + Overview -------- @@ -75,4 +77,4 @@ and then request area of interest from their name or GADM Id: Credits ------- -This package was created with `Copier `__ and the `@12rambau/pypackage `__ 0.1.11 project template. +This package was created with `Copier `__ and the `@12rambau/pypackage `__ 0.1.16 project template. diff --git a/docs/_static/custom-icon.js b/docs/_static/custom-icon.js new file mode 100644 index 0000000..d947d8a --- /dev/null +++ b/docs/_static/custom-icon.js @@ -0,0 +1,16 @@ +/******************************************************************************* + * Set a custom icon for pypi as it's not available in the fa built-in brands + */ +FontAwesome.library.add( + (faListOldStyle = { + prefix: "fa-custom", + iconName: "conda", + icon: [ + 24, // viewBox width + 24, // viewBox height + [], // ligature + "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) + ], + }), +); diff --git a/docs/_template/pypackage-credit.html b/docs/_template/pypackage-credit.html index bd76288..2a399da 100644 --- a/docs/_template/pypackage-credit.html +++ b/docs/_template/pypackage-credit.html @@ -1,5 +1,5 @@

From @12rambau/pypackage - 0.1.11 Copier project. + 0.1.16 Copier project.

diff --git a/docs/conf.py b/docs/conf.py index 741d53f..afad2ac 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,6 +64,12 @@ "url": "https://pypi.org/project/pygadm", "icon": "fa-brands fa-python", }, + { + "name": "Conda", + "url": "https://anaconda.org/conda-forge/pygadm", + "icon": "fa-custom fa-conda", + "type": "fontawesome", + }, ], } html_context = { diff --git a/noxfile.py b/noxfile.py index d604f32..7984872 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 @@ -10,37 +11,36 @@ nox.options.sessions = ["lint", "test", "docs", "mypy"] -@nox.session(reuse_venv=True) +@nox.session(reuse_venv=True, venv_backend="uv") def lint(session): """Apply the pre-commits.""" session.install("pre-commit") session.run("pre-commit", "run", "--all-files", *session.posargs) -@nox.session(reuse_venv=True) +@nox.session(reuse_venv=True, venv_backend="uv") def test(session): """Run the selected tests and report coverage in html.""" session.install(".[test]") test_files = session.posargs or ["tests"] - session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files) + session.run("pytest", "--cov", "--cov-report=html", *test_files) -@nox.session(reuse_venv=True, name="ci-test") +@nox.session(reuse_venv=True, name="ci-test", venv_backend="uv") def ci_test(session): """Run all the test and report coverage in xml.""" session.install(".[test]") - session.posargs[0] if session.posargs else "default" - session.run("pytest", "--color=yes", "--cov", "--cov-report=xml") + session.run("pytest", "--cov", "--cov-report=xml") -@nox.session(reuse_venv=True, name="dead-fixtures") +@nox.session(reuse_venv=True, name="dead-fixtures", venv_backend="uv") def dead_fixtures(session): """Check for dead fixtures within the tests.""" session.install(".[test]") session.run("pytest", "--dead-fixtures") -@nox.session(reuse_venv=True) +@nox.session(reuse_venv=True, venv_backend="uv") def docs(session): """Build the documentation.""" build = session.posargs.pop() if session.posargs else "html" @@ -50,15 +50,15 @@ def docs(session): session.run("python", "tests/check_warnings.py") -@nox.session(name="mypy", reuse_venv=True) +@nox.session(name="mypy", reuse_venv=True, venv_backend="uv") def mypy(session): """Run a mypy check of the lib.""" - session.install("mypy") + session.install("mypy", "types-deprecated") test_files = session.posargs or ["pygadm"] session.run("mypy", *test_files) -@nox.session(reuse_venv=True) +@nox.session(reuse_venv=True, venv_backend="uv") def stubgen(session): """Generate stub files for the lib but requires human attention before merge.""" session.install("mypy") @@ -66,7 +66,7 @@ def stubgen(session): session.run("stubgen", "-p", package[0], "-o", "stubs", "--include-private") -@nox.session(name="release-date", reuse_venv=True) +@nox.session(name="release-date", reuse_venv=True, venv_backend="uv") def release_date(session): """Update the release date of the citation file.""" current_date = datetime.datetime.now().strftime("%Y-%m-%d") diff --git a/pygadm/bin/refresh_database.py b/pygadm/bin/refresh_database.py index e1fb38b..8750318 100644 --- a/pygadm/bin/refresh_database.py +++ b/pygadm/bin/refresh_database.py @@ -22,7 +22,6 @@ parser = argparse.ArgumentParser(description=__doc__, usage="refresh_database") if __name__ == "__main__": - # read arguments parser.add_argument( "-f", @@ -41,7 +40,6 @@ # read the all the geodata available in the server at once with tempfile.TemporaryDirectory() as tmp_dir: - # check if a download is required if vars(args)["gadm_src"] is not None: zip_file = Path(vars(args)["gadm_src"]) diff --git a/pyproject.toml b/pyproject.toml index 0760f9b..dc9f9a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,6 @@ Homepage = "https://github.com/12rambau/pygadm" [project.optional-dependencies] test = [ "pytest", - "pytest-sugar", "pytest-cov", "pytest-deadfixtures", "pytest-regressions>=2.4.3", # https://github.com/ESSS/pytest-regressions/issues/136 @@ -70,7 +69,7 @@ only-include = ["pygadm"] dependencies = [ "pre-commit", "commitizen", - "nox" + "nox[uv]" ] post-install-commands = ["pre-commit install"] @@ -87,32 +86,28 @@ version_files = [ [tool.pytest.ini_options] testpaths = "tests" -[tool.black] -line-length = 100 - [tool.ruff] -ignore-init-module-imports = true +line-length = 100 fix = true + +[tool.ruff.lint] select = ["E", "F", "W", "I", "D", "RUF"] ignore = [ "E501", # line too long | Black take care of it - "W605", # invalid escape sequence | we escape specific characters for sphinx - "D212", # Multi-line docstring | we use a different convention, too late - "D101", # Missing docstring in public class | we use a different convention, too late + "W605", # invalid escape sequence | we escape specific characters for sphinx + "D212", # Multi-line docstring | we use a different convention, too late + "D101", # Missing docstring in public class | we use a different convention, too late ] -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] docstring-quotes = "double" -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" [tool.coverage.run] source = ["pygadm"] -[tool.doc8] -ignore = ["D001"] # we follow a 1 line = 1 paragraph style - [tool.mypy] scripts_are_modules = true ignore_missing_imports = true @@ -120,8 +115,5 @@ install_types = true non_interactive = true warn_redundant_casts = true -[tool.licensecheck] -using = "PEP631" - [tool.codespell] skip = 'CHANGELOG.md,**/*.json,**/*.csv' 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/tests/test_continent.py b/tests/test_continent.py index 6bfcede..37ccc2c 100644 --- a/tests/test_continent.py +++ b/tests/test_continent.py @@ -1,4 +1,5 @@ """Tests of the continents submanagement.""" + import json from pathlib import Path