Skip to content

Commit 417ce6c

Browse files
Merge pull request #345 from tpvasconcelos/upgrade-python-support
Drop support for Python 3.9, upgrade default dev version to 3.10, and add support for 3.14
2 parents 321c4c6 + c537d45 commit 417ce6c

28 files changed

Lines changed: 134 additions & 225 deletions

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1717

1818
jobs:
19-
# Run static checks only for Ubuntu and Python 3.9
19+
# Run static checks only for Ubuntu and the lowest support version of Python
2020
static-checks:
2121
name: Static checks
2222
runs-on: ubuntu-latest
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v5
2626
- uses: ./.github/actions/setup-python
2727
with:
28-
python-version: "3.9"
28+
python-version: "3.10"
2929
requirements: tox
3030
# Instead of running all checks in one task (i.e., `tox -m static`),
3131
# we'll instead run them one-by-one, so that it's easier to
@@ -47,11 +47,11 @@ jobs:
4747
strategy:
4848
matrix:
4949
python-version:
50-
- "3.9"
5150
- "3.10"
5251
- "3.11"
5352
- "3.12"
5453
- "3.13"
54+
#- "3.14"
5555
os:
5656
- ubuntu-latest
5757
# There shouldn't be any behavior differences between OSes,

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
fetch-depth: 0
4040
- uses: ./.github/actions/setup-python
4141
with:
42-
python-version: "3.9"
42+
python-version: "3.10"
4343
requirements: tox
4444
- name: Build source (sdist) and binary (wheel) distributions
4545
run: tox -e build-dists
@@ -112,7 +112,7 @@ jobs:
112112
fetch-depth: 0
113113
- uses: ./.github/actions/setup-python
114114
with:
115-
python-version: "3.9"
115+
python-version: "3.10"
116116
requirements: tox
117117
- name: Generate release notes
118118
run: tox -e release-notes

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
default_language_version:
2-
python: python3.9
2+
python: python3.10
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version: 2
55
build:
66
os: ubuntu-lts-latest
77
tools:
8-
python: "3.9"
8+
python: "3.10"
99
apt_packages:
1010
# chromium-browser is required by Kaleido to generate Plotly figures via fig.write_image()
1111
- chromium-browser

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# >>> Variables
33
# ==============================================================
44

5-
BASE_PYTHON ?= python3.9
5+
BASE_PYTHON ?= python3.10
66

77
VENV_PATH := .venv
88
VENV_BIN := $(VENV_PATH)/bin

docs/conf.py

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from __future__ import annotations
22

3+
import ast
34
import importlib.metadata
5+
import inspect
6+
import pkgutil
47
import sys
58
from contextlib import contextmanager
69
from datetime import datetime
@@ -10,6 +13,8 @@
1013

1114
from typing_extensions import Any
1215

16+
import ridgeplot as ridgeplot_pkg
17+
1318
try:
1419
from ridgeplot_examples import ALL_EXAMPLES
1520
except ImportError:
@@ -271,47 +276,49 @@
271276

272277

273278
# Type aliases
274-
_TYPE_ALIASES_FULLY_QUALIFIED = {
275-
# ------- ._color.css_colors -------------------
276-
"ridgeplot._color.css_colors.CssNamedColor",
277-
# ------- ._color.interpolation ----------------
278-
"ridgeplot._color.interpolation.ColorscaleInterpolants",
279-
"ridgeplot._color.interpolation.SolidColormode",
280-
# ------- ._kde --------------------------------
281-
"ridgeplot._kde.KDEPoints",
282-
"ridgeplot._kde.KDEBandwidth",
283-
# ------- ._missing ----------------------------
284-
"ridgeplot._missing.MISSING",
285-
"ridgeplot._missing.MissingType",
286-
# ------- ._types ------------------------------
287-
"ridgeplot._types.Color",
288-
"ridgeplot._types.ColorScale",
289-
"ridgeplot._types.NormalisationOption",
290-
"ridgeplot._types.CollectionL1",
291-
"ridgeplot._types.CollectionL2",
292-
"ridgeplot._types.CollectionL3",
293-
"ridgeplot._types.Float",
294-
"ridgeplot._types.Int",
295-
"ridgeplot._types.Numeric",
296-
"ridgeplot._types.NumericT",
297-
"ridgeplot._types.XYCoordinate",
298-
"ridgeplot._types.DensityTrace",
299-
"ridgeplot._types.DensitiesRow",
300-
"ridgeplot._types.Densities",
301-
"ridgeplot._types.ShallowDensities",
302-
"ridgeplot._types.SamplesTrace",
303-
"ridgeplot._types.SamplesRow",
304-
"ridgeplot._types.Samples",
305-
"ridgeplot._types.ShallowSamples",
306-
"ridgeplot._types.TraceType",
307-
"ridgeplot._types.TraceTypesArray",
308-
"ridgeplot._types.ShallowTraceTypesArray",
309-
"ridgeplot._types.LabelsArray",
310-
"ridgeplot._types.ShallowLabelsArray",
311-
"ridgeplot._types.SampleWeights",
312-
"ridgeplot._types.SampleWeightsArray",
313-
"ridgeplot._types.ShallowSampleWeightsArray",
314-
}
279+
def _get_module_type_aliases(module_name: str) -> set[str]:
280+
module = import_module(module_name)
281+
source = inspect.getsource(module)
282+
tree = ast.parse(source)
283+
type_aliases = {
284+
f"{module_name}.{node.target.id}"
285+
for node in ast.walk(tree)
286+
# Handle annotated assignments: x: TypeAlias = ...
287+
if (
288+
isinstance(node, ast.AnnAssign)
289+
and isinstance(node.target, ast.Name)
290+
and isinstance(node.annotation, ast.Name)
291+
and node.annotation.id == "TypeAlias"
292+
)
293+
}
294+
return type_aliases
295+
296+
297+
def _get_package_type_aliases(package_name: str) -> set[str]:
298+
"""Recursively extract TypeAlias definitions from a package."""
299+
package = import_module(package_name)
300+
prefix = f"{package.__name__}."
301+
type_aliases = set()
302+
for _, modname, is_pkg in pkgutil.walk_packages(package.__path__, prefix):
303+
if is_pkg:
304+
type_aliases.update(_get_package_type_aliases(modname))
305+
else:
306+
type_aliases.update(_get_module_type_aliases(modname))
307+
return type_aliases
308+
309+
310+
_TYPE_ALIASES_FULLY_QUALIFIED = (
311+
# Automatically extract all TypeAlias
312+
# definitions from the `ridgeplot` package
313+
_get_package_type_aliases(ridgeplot_pkg.__name__)
314+
| {
315+
# `MISSING` is a special case that is
316+
# widely referenced in type annotations
317+
"ridgeplot._missing.MISSING",
318+
# Same thing with the `NumericT` TypeVar
319+
"ridgeplot._types.NumericT",
320+
}
321+
)
315322
for fq in _TYPE_ALIASES_FULLY_QUALIFIED:
316323
module_name, _, type_name = fq.rpartition(".")
317324
try:

docs/development/contributing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Here are our guidelines for setting a **working** development environment. Most
2626
:::{admonition} Prerequisites
2727
:class: important
2828

29-
To follow along with this guide, you will need to have [git](https://git-scm.com/), [make](https://www.gnu.org/software/make/), and [uv](https://docs.astral.sh/uv/) installed on your system. We recommend using [uv](https://docs.astral.sh/uv/guides/install-python/) to also manage your Python installations. For this project you will need Python 3.9 or higher.
29+
To follow along with this guide, you will need to have [git](https://git-scm.com/), [make](https://www.gnu.org/software/make/), and [uv](https://docs.astral.sh/uv/) installed on your system. We recommend using [uv](https://docs.astral.sh/uv/guides/install-python/) to also manage your Python installations. For this project you will need Python 3.10 or higher.
3030
:::
3131

3232
First, you will need to [clone](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#step-2-create-a-local-clone-of-your-fork) this repository. For this, make sure you have a [GitHub account](https://github.com/join), fork ridgeplot by clicking the [Fork](https://github.com/tpvasconcelos/ridgeplot/fork) button, and clone the main repository locally (_e.g.,_ using SSH)
@@ -55,10 +55,10 @@ The following command will:
5555
make init
5656
```
5757

58-
The default and **recommended** base Python is `python3.9`. However, if you encounter any issues or don't have this specific version installed on your system, you can change by it exporting the `BASE_PYTHON` environment variable to a valid executable you do have installed. Please note that we no longer support any Python versions lower than 3.9. For example, to use `python3.13`, you should run:
58+
The default and **recommended** base Python is `python3.10`. However, if you encounter any issues or don't have this specific version installed on your system, you can change by it exporting the `BASE_PYTHON` environment variable to a valid executable you do have installed. Please note that we no longer support any Python versions lower than 3.10. For example, to use `python3.14`, you should run:
5959

6060
```shell
61-
BASE_PYTHON=python3.13 make init
61+
BASE_PYTHON=python3.14 make init
6262
```
6363

6464
If for whatever reason you don't have a working internet connection (✈️, ⛵, 🏕️, 🚀, etc.), you can try exposing the `OFFLINE=1` environment variable. This will only work if compatible packages have already been cached by `uv` on your system.

docs/reference/changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ This document outlines the list of changes to ridgeplot between each release. Fo
55
Unreleased changes
66
------------------
77

8+
- Dropped support for Python 3.9, in accordance with the official Python support policy[^1] ({gh-pr}`345`)
89
- Bump project classification from Pre-Alpha to Alpha ({gh-pr}`336`)
9-
- Bump actions/github-script from 7 to 8 ({gh-pr}`338`)
1010

1111
### CI/CD
1212

13+
- Bump actions/github-script from 7 to 8 ({gh-pr}`338`)
1314
- pre-commit autoupdate ({gh-pr}`340`)
1415

1516
---

misc/brand/logo.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"outputs": [],
4848
"source": [
49-
"from typing import TYPE_CHECKING, Union\n",
49+
"from typing import TYPE_CHECKING\n",
5050
"\n",
5151
"import matplotlib.pyplot as plt\n",
5252
"import numpy as np\n",
@@ -70,7 +70,7 @@
7070
},
7171
"outputs": [],
7272
"source": [
73-
"ColorsRow = Union[str, list[str]]\n",
73+
"ColorsRow = str | list[str]\n",
7474
"Colors = tuple[ColorsRow, ColorsRow, ColorsRow, ColorsRow]\n",
7575
"\n",
7676
"\n",

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[mypy]
2-
python_version = 3.9
2+
python_version = 3.10
33

44
# Import discovery ---
55
files = src/ridgeplot, tests, docs, cicd_utils

0 commit comments

Comments
 (0)