From a8b1a8344fc2eabac61bdd3f32c446a94838d063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sat, 26 Oct 2024 17:28:09 +0200 Subject: [PATCH] MNT: migrate requirement files to PEP 735 dependency groups --- .github/workflows/test.yml | 18 +++++++----------- MANIFEST.in | 1 - pyproject.toml | 19 ++++++++++++++++++- requirements/dev.txt | 4 ---- requirements/typecheck.txt | 2 -- src/cmasher/utils.py | 2 +- 6 files changed, 26 insertions(+), 20 deletions(-) delete mode 100644 requirements/dev.txt delete mode 100644 requirements/typecheck.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7938e6b4..1210635d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,6 @@ jobs: - '3.11' - '3.12' - '3.13' - test-args: [viscm>=0.10] include: - os: ubuntu-20.04 @@ -64,18 +63,19 @@ jobs: run: | uv venv --python ${{ matrix.python-version }} uv pip install . - uv pip install -r requirements/dev.txt ${{ matrix.test-args }} + uv pip install -r requirements/dev.txt - run: uv pip list - name: Test package (no coverage) if: ${{ !startsWith( matrix.os , 'ubuntu' ) }} - run: uv run --no-editable pytest --color=yes --mpl + run: uv run --no-editable --verbose --group test pytest --color=yes --mpl - name: Test package (with coverage) if: startsWith( matrix.os , 'ubuntu' ) run: | - uv run --no-editable coverage run --parallel-mode -m pytest --color=yes --mpl + uv run --no-editable --verbose --group test \ + coverage run --parallel-mode -m pytest --color=yes --mpl - name: Upload coverage data # only using reports from ubuntu because @@ -97,9 +97,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: astral-sh/setup-uv@3b9817b1bf26186f03ab8277bab9b827ea5cc254 # v3.2.0 - - run: | # uv sync --only-group covcheck - uv venv - uv pip install -r requirements/dev.txt + - run: uv sync --only-group covcheck - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -123,6 +121,7 @@ jobs: name: type check w/ Python ${{ matrix.python-version }} strategy: + fail-fast: false matrix: python-version: - '3.10' @@ -142,10 +141,7 @@ jobs: cache-dependency-glob: pyproject.toml - name: Run mypy - run: | - uvx --python ${{ matrix.python-version }} \ - --with-requirements=requirements/typecheck.txt --with . \ - mypy src/cmasher + run: uv run -p ${{ matrix.python-version }} --group typecheck mypy src/cmasher docs: name: Build docs diff --git a/MANIFEST.in b/MANIFEST.in index 35fe7ad4..5bacba50 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,6 @@ include LICENSE include CITATION include README.rst include MANIFEST.in -include requirements/*.txt include conftest.py recursive-include cmasher data/* recursive-exclude cmasher/colormaps * diff --git a/pyproject.toml b/pyproject.toml index d622f014..66255da1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,13 +45,30 @@ Documentation = "https://cmasher.readthedocs.io" [project.scripts] cmr = "cmasher.cli_tools:main" +[dependency-groups] +covcheck = [ + "coverage[toml]>=7.6.4", +] +test = [ + "pytest>=8.1.1", + "pytest-mpl>=0.13.0", + {include-group = "covcheck"}, +] +typecheck = [ + "mypy>=1.7.1", +] +dev = [ + {include-group = "test"}, + {include-group = "typecheck"}, +] + [tool.hatch.build] exclude = [ "scripts", ] [tool.pytest.ini_options] -addopts = "-v" +addopts = "-v -ra" filterwarnings = [ "error", "ignore:FigureCanvasAgg is non-interactive:UserWarning", diff --git a/requirements/dev.txt b/requirements/dev.txt deleted file mode 100644 index dcaf4bbf..00000000 --- a/requirements/dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -coverage[toml]>=7.6.4 -pyqt5>=5.15.6 -pytest>=8.1.1 -pytest-mpl>=0.13.0 diff --git a/requirements/typecheck.txt b/requirements/typecheck.txt deleted file mode 100644 index 0aef747d..00000000 --- a/requirements/typecheck.txt +++ /dev/null @@ -1,2 +0,0 @@ -mypy==1.7.1 -pytest==7.4.3 diff --git a/src/cmasher/utils.py b/src/cmasher/utils.py index 53fe17ce..7f9a7d6b 100644 --- a/src/cmasher/utils.py +++ b/src/cmasher/utils.py @@ -1545,7 +1545,7 @@ def take_cmap_colors( # Convert colors to proper format if return_fmt in ("float", "norm", "int", "8bit"): - colors = np.apply_along_axis(to_rgb, 1, colors) # type: ignore [arg-type] + colors = np.apply_along_axis(to_rgb, 1, colors) # type: ignore [call-overload] if return_fmt in ("int", "8bit"): colors = np.array(np.rint(colors * 255), dtype=int) colors = list(map(tuple, colors))