Skip to content

Commit a8bb835

Browse files
Merge pull request yt-project#138 from neutrinoceros/drop_cp38
DEP: drop support for CPython 3.8
2 parents d379d61 + 3163bad commit a8bb835

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ jobs:
1616
os:
1717
- ubuntu-latest
1818
python-version:
19-
- '3.8'
2019
- '3.9'
2120
- '3.10'
2221
- '3.11'
2322
include:
2423
# only test oldest and most recent Python on other platforms
2524
- os: macos-latest
26-
python-version: '3.8'
25+
python-version: '3.9'
2726
- os: macos-latest
2827
python-version: '3.11'
2928
- os: windows-latest
30-
python-version: '3.8'
29+
python-version: '3.9'
3130
- os: windows-latest
3231
python-version: '3.11'
3332
runs-on: ${{ matrix.os }}
@@ -61,7 +60,7 @@ jobs:
6160
- name: Setup Python
6261
uses: actions/setup-python@v4
6362
with:
64-
python-version: '3.8'
63+
python-version: '3.9'
6564
- name: Build library
6665
run: |
6766
python -m pip install --upgrade pip
@@ -130,7 +129,7 @@ jobs:
130129
matrix:
131130
python-version:
132131
# oldest and newest supported versions
133-
- '3.8'
132+
- '3.9'
134133
- '3.11'
135134
concurrency:
136135
# auto-cancel any in-progress job *on the same branch*

cmyt/utils.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
import os
2-
import sys
3-
from typing import (
4-
TYPE_CHECKING,
5-
Any,
6-
Dict,
7-
Final,
8-
Iterable,
9-
Literal,
10-
Optional,
11-
Sequence,
12-
Tuple,
13-
)
2+
import warnings
3+
from collections.abc import Iterable, Sequence
4+
from typing import TYPE_CHECKING, Any, Final, Literal, Optional
145

156
import matplotlib as mpl
167
import numpy as np
@@ -24,7 +15,7 @@
2415

2516
_CMYT_PREFIX: Final[str] = "cmyt."
2617

27-
ColorDict = Dict[Literal["red", "green", "blue", "alpha"], Sequence[Tuple[float, ...]]]
18+
ColorDict = dict[Literal["red", "green", "blue", "alpha"], Sequence[tuple[float, ...]]]
2819

2920
# this is used in cmyt.cm to programmatically import all cmaps
3021
cmyt_cmaps = frozenset(
@@ -59,20 +50,22 @@ def unprefix_name(name: str) -> str:
5950
>>> unprefix_name("arbre")
6051
'arbre'
6152
"""
62-
if sys.version_info >= (3, 9):
63-
return name.removeprefix(_CMYT_PREFIX)
64-
else:
65-
if name.startswith(_CMYT_PREFIX):
66-
return name[len(_CMYT_PREFIX) :]
67-
return name
53+
warnings.warn(
54+
"cmyt.utils.unprefix_name is deprecated since version 1.4.0 "
55+
"and will be removed in a future version. "
56+
"Instead, use name.removeprefix('cmyt.')",
57+
category=DeprecationWarning,
58+
stacklevel=2,
59+
)
60+
return name.removeprefix(_CMYT_PREFIX)
6861

6962

7063
def register_colormap(
7164
name: str,
7265
*,
7366
color_dict: Optional[ColorDict] = None,
7467
colors: Optional[np.ndarray] = None,
75-
) -> Tuple[Colormap, Colormap]:
68+
) -> tuple[Colormap, Colormap]:
7669
name = prefix_name(name)
7770

7871
if color_dict is not None and colors is not None:
@@ -91,8 +84,8 @@ def register_colormap(
9184
mpl.colormaps.register(cmap_r)
9285

9386
# return cmaps with unprefixed names for registration as importable objects
94-
cmap.name = unprefix_name(cmap.name)
95-
cmap_r.name = unprefix_name(cmap_r.name)
87+
cmap.name = cmap.name.removeprefix(_CMYT_PREFIX)
88+
cmap_r.name = cmap_r.name.removeprefix(_CMYT_PREFIX)
9689
return cmap, cmap_r
9790

9891

@@ -184,7 +177,9 @@ def create_cmap_overview(
184177
for rgb, _ax in zip(RGBs, _axes):
185178
_ax.axis("off")
186179
show_cmap(_ax, rgb)
187-
ax.text(ax.get_xlim()[1] * 1.02, 0, unprefix_name(name), fontsize=10)
180+
ax.text(
181+
ax.get_xlim()[1] * 1.02, 0, name.removeprefix(_CMYT_PREFIX), fontsize=10
182+
)
188183

189184
fig.tight_layout(h_pad=0.2)
190185
fig.subplots_adjust(top=0.9, bottom=0.05, right=0.85, left=0.05)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ classifiers = [
2323
keywords = [
2424
"visualization",
2525
]
26-
requires-python = ">=3.8"
26+
requires-python = ">=3.9"
2727
dependencies = [
2828
"matplotlib>=3.5.0",
29-
"numpy>=1.17.4",
29+
"numpy>=1.19.3",
3030
]
3131
dynamic = ["version"]
3232

@@ -72,7 +72,7 @@ select = [
7272
combine-as-imports = true
7373

7474
[tool.mypy]
75-
python_version = "3.8"
75+
python_version = "3.9"
7676
warn_unused_configs = true
7777
warn_unused_ignores = true
7878
warn_unreachable = true

0 commit comments

Comments
 (0)