Skip to content

Commit 21c8fc5

Browse files
authored
build: drop py38 (#94)
* build: drop py38 * shorten * update pyproject * add back license files * drop 38 * pin numba
1 parent a540089 commit 21c8fc5

File tree

12 files changed

+43
-57
lines changed

12 files changed

+43
-57
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
35+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
3636
platform: [ubuntu-latest, macos-latest, windows-latest]
3737

3838
steps:
@@ -77,32 +77,32 @@ jobs:
7777
deploy:
7878
name: Deploy
7979
needs: test
80-
if: "success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'"
80+
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
8181
runs-on: ubuntu-latest
8282

83+
permissions:
84+
id-token: write
85+
contents: write
86+
8387
steps:
8488
- uses: actions/checkout@v4
89+
with:
90+
fetch-depth: 0
8591

8692
- name: Set up Python
8793
uses: actions/setup-python@v5
8894
with:
8995
python-version: "3.x"
9096

91-
- name: install
97+
- name: 👷 Build
9298
run: |
93-
git tag
94-
pip install -U pip
95-
pip install -U build twine
99+
python -m pip install build
96100
python -m build
97-
twine check dist/*
98-
ls -lh dist
99101
100-
- name: Build and publish
101-
run: twine upload dist/*
102-
env:
103-
TWINE_USERNAME: __token__
104-
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
102+
- name: 🚢 Publish to PyPI
103+
uses: pypa/gh-action-pypi-publish@release/v1
105104

106105
- uses: softprops/action-gh-release@v2
107106
with:
108107
generate_release_notes: true
108+
files: "./dist/*"

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v4
1313
- uses: actions/setup-python@v5
1414
with:
15-
python-version: '3.11'
15+
python-version: '3.12'
1616
- run: |
1717
pip install -e .[docs]
1818
- run: mkdocs gh-deploy --strict --force

docs/_hooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import base64
22
import re
33
import sys
4+
from collections.abc import Sequence
45
from functools import partial
56
from pathlib import Path
6-
from typing import TYPE_CHECKING, Any, Sequence, cast
7+
from typing import TYPE_CHECKING, Any, cast
78

89
import natsort
910
import numpy as np

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ build-backend = "hatchling.build"
88
name = "cmap"
99
description = "Scientific colormaps for python, without dependencies"
1010
readme = "README.md"
11-
requires-python = ">=3.8"
11+
requires-python = ">=3.9"
1212
license = "BSD-3-Clause"
1313
license-files = ["LICENSE/*"]
1414
authors = [{ email = "[email protected]", name = "Talley Lambert" }]
1515
classifiers = [
1616
"Development Status :: 4 - Beta",
1717
"License :: OSI Approved :: BSD License",
1818
"Programming Language :: Python :: 3",
19-
"Programming Language :: Python :: 3.8",
2019
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
@@ -50,8 +49,9 @@ test_thirdparty = [
5049
"colorspacious",
5150
"colour",
5251
"matplotlib",
53-
"napari>=0.4.19; python_version<'3.13'",
54-
"numba; python_version<'3.13' and platform_machine != 'arm64'",
52+
"napari>=0.5.0",
53+
"numba",
54+
"numba<0.61; python_version<'3.12'",
5555
"plotly",
5656
"pydantic-extra-types>=2,!=2.10.1",
5757
"pydantic",
@@ -93,7 +93,7 @@ include = ["/src", "/tests", "CHANGELOG.md"]
9393
# https://github.com/charliermarsh/ruff
9494
[tool.ruff]
9595
line-length = 88
96-
target-version = "py38"
96+
target-version = "py39"
9797
src = ["src"]
9898

9999
[tool.ruff.lint]

src/cmap/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Scientific colormaps for python, without dependencies."""
22

33
from importlib.metadata import PackageNotFoundError, version
4-
from typing import TYPE_CHECKING, Iterator, Mapping
4+
from typing import TYPE_CHECKING
55

66
try:
77
__version__ = version("cmap")
@@ -14,6 +14,8 @@
1414
from ._util import to_mpl
1515

1616
if TYPE_CHECKING:
17+
from collections.abc import Iterator, Mapping
18+
1719
from ._catalog import CatalogItem
1820

1921
class Catalog(Mapping[str, CatalogItem]):

src/cmap/_catalog.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,10 @@
1010

1111
import json
1212
import logging
13+
from collections.abc import Container, Iterable, Iterator, Mapping
1314
from dataclasses import dataclass, field
1415
from pathlib import Path
15-
from typing import (
16-
TYPE_CHECKING,
17-
Any,
18-
Container,
19-
Iterable,
20-
Iterator,
21-
Literal,
22-
Mapping,
23-
cast,
24-
)
16+
from typing import TYPE_CHECKING, Any, Literal, cast
2517

2618
import cmap.data
2719

src/cmap/_color.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
import contextlib
77
import re
88
import sys
9+
from collections.abc import Iterable, Sequence
910
from typing import (
1011
TYPE_CHECKING,
1112
Any,
1213
Callable,
13-
Iterable,
14-
List,
1514
Literal,
1615
NamedTuple,
17-
Sequence,
1816
SupportsFloat,
1917
Union,
2018
cast,
@@ -53,7 +51,7 @@
5351
RGBTuple, # 3-tuple of all ints or all floats
5452
RGBATuple, # 4-tuple of all floats, or 3 ints and 1 float
5553
np.ndarray, # 3- or 4-element rgb(a) vector
56-
List[Union[float, int]], # 3- or 4-element rgb(a) vector
54+
list[Union[float, int]], # 3- or 4-element rgb(a) vector
5755
"Color", # another color object
5856
]
5957
"""Data types that can be cast to a [cmap.Color][] instance.

src/cmap/_colormap.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,10 @@
44

55
import base64
66
import warnings
7+
from collections.abc import Iterable, Sequence
78
from functools import partial
89
from numbers import Number
9-
from typing import (
10-
TYPE_CHECKING,
11-
Any,
12-
Callable,
13-
Dict,
14-
Iterable,
15-
NamedTuple,
16-
Sequence,
17-
Tuple,
18-
Union,
19-
cast,
20-
overload,
21-
)
10+
from typing import TYPE_CHECKING, Any, Callable, NamedTuple, Union, cast, overload
2211

2312
import numpy as np
2413
import numpy.typing as npt
@@ -28,7 +17,8 @@
2817
from ._color import Color, ColorLike
2918

3019
if TYPE_CHECKING:
31-
from typing import Iterator, Literal
20+
from collections.abc import Iterator
21+
from typing import Literal
3222

3323
import bokeh.models
3424
import matplotlib.colors
@@ -63,7 +53,7 @@ class ColormapDict(TypedDict):
6353
LutCallable: TypeAlias = Callable[["NDArray"], "NDArray"]
6454
"""Function type for a callable that takes an array of values in the range [0, 1] and returns an (N, 4) array of RGBA values in the range [0, 1].""" # noqa
6555

66-
ColorStopLike: TypeAlias = Union[Tuple[float, ColorLike], "NDArray"]
56+
ColorStopLike: TypeAlias = Union[tuple[float, ColorLike], "NDArray"]
6757
"""A single color-stop: 2-tuple of a scalar "stop" value and a color-like object, or an array of color-like objects.""" # noqa
6858

6959
# All of the things that we can pass to the constructor of Colormap
@@ -72,7 +62,7 @@ class ColormapDict(TypedDict):
7262
Iterable[Union[ColorLike, ColorStopLike]],
7363
"NDArray",
7464
"MPLSegmentData",
75-
Dict[float, ColorLike],
65+
dict[float, ColorLike],
7666
"ColorStops",
7767
LutCallable,
7868
]

src/cmap/_util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
from __future__ import annotations
22

33
import sys
4-
from typing import TYPE_CHECKING, Sequence, TypedDict, cast
4+
from typing import TYPE_CHECKING, TypedDict, cast
55

66
import numpy as np
77

88
gradient = np.linspace(0, 1, 256)
99
gradient = np.vstack((gradient, gradient))
1010

1111
if TYPE_CHECKING:
12+
from collections.abc import Sequence
13+
1214
import matplotlib.colors
1315
from matplotlib.figure import Figure as MplFigure
1416
from numpy.typing import ArrayLike, NDArray

src/cmap/data/glasbey/_grids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# see __init__ and LICENSE_GLASBEY
33
from __future__ import annotations
44

5-
from typing import Sized
5+
from collections.abc import Sized
66

77
import numpy as np
88

src/cmap/data/gnuplot/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
# 36: 2*x - 1
5353
"""
5454

55+
from collections.abc import Sequence
5556
from functools import partial
56-
from typing import TYPE_CHECKING, Sequence
57+
from typing import TYPE_CHECKING
5758

5859
import numpy as np
5960

tests/test_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Set, cast
1+
from typing import TYPE_CHECKING, cast
22

33
import numpy as np
44
import numpy.testing as npt
@@ -9,7 +9,7 @@
99
try:
1010
import matplotlib as mpl
1111

12-
MPL_CMAPS: Set[str] = {c for c in mpl.colormaps if not c.endswith("_r")}
12+
MPL_CMAPS: set[str] = {c for c in mpl.colormaps if not c.endswith("_r")}
1313
except ImportError:
1414
MPL_CMAPS = {}
1515

@@ -32,7 +32,7 @@ def test_napari_name_parity() -> None:
3232
pytest.importorskip("napari")
3333
import napari.utils.colormaps.colormap_utils as ncm
3434

35-
napari_cmaps: Set[str] = set(ncm.AVAILABLE_COLORMAPS)
35+
napari_cmaps: set[str] = set(ncm.AVAILABLE_COLORMAPS)
3636
napari_cmaps.update(ncm._VISPY_COLORMAPS_ORIGINAL)
3737
napari_cmaps.update(ncm._MATPLOTLIB_COLORMAP_NAMES)
3838
# TODO: later it would be good to make sure we can accept all strings

0 commit comments

Comments
 (0)