Skip to content

Commit

Permalink
MNT: migrate requirement files to PEP 735 dependency groups
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 28, 2024
1 parent 3aeec21 commit 0004f89
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
- '3.11'
- '3.12'
- '3.13'
test-args: [viscm>=0.10]

include:
- os: ubuntu-20.04
Expand Down Expand Up @@ -61,21 +60,22 @@ jobs:
echo "UV_RESOLUTION=lowest-direct" >> $GITHUB_ENV
- name: Build
shell: bash # for windows-compat
run: |
uv venv --python ${{ matrix.python-version }}
uv venv -p ${{ matrix.python-version }}
uv pip install .
uv pip install -r requirements/dev.txt ${{ matrix.test-args }}
- 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
Expand All @@ -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:
Expand All @@ -123,6 +121,7 @@ jobs:
name: type check w/ Python ${{ matrix.python-version }}

strategy:
fail-fast: false
matrix:
python-version:
- '3.10'
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions requirements/dev.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/typecheck.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/cmasher/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 0004f89

Please sign in to comment.