Skip to content

Commit ce6c511

Browse files
authored
nitypes: Add support for Python 3.15 and remove support for Python 3.9 and 3.10 (#293)
* nitypes: Add Python 3.15 and remove Python 3.9 Signed-off-by: Brad Keryan <brad.keryan@ni.com> * chore: Update poetry.lock Signed-off-by: Brad Keryan <brad.keryan@ni.com> * github: Update check_nitypes.yml to run on Python 3.15 Signed-off-by: Brad Keryan <brad.keryan@ni.com> * github: Call ensurepip before pip * Revert "github: Call ensurepip before pip" This reverts commit 9b4a4b6. * github: Call ensurepip --upgrade before installing Poetry * github: Replace pip with importlib.metadata * github: Show dependencies in sorted order * nitypes: Drop Python 3.10 as well * chore: Update poetry.lock * github: Restore comment about pinning Python versions * nitypes: Update minimum required NumPy version * chore: Update poetry.lock * nitypes: Add a NumPy version block for testing with Python 3.15 * chore: Update poetry.lock * tests: Ignore a couple new pyright assert_type failures regarding int vs. Literal[3] * tests: Add a comment * tests: Fix formatting * tests: Move pyright ignores to the correct lines --------- Signed-off-by: Brad Keryan <brad.keryan@ni.com>
1 parent 9360561 commit ce6c511

8 files changed

Lines changed: 192 additions & 973 deletions

File tree

‎.github/workflows/check_nitypes.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
os: [windows-latest, ubuntu-latest, macos-latest]
1515
# Type checking requires an up-to-date NumPy.
1616
# The latest NumPy only supports 3.11 and later
17-
# Pin to 3.14.8 to workaround AB#4147280
18-
python-version: [3.11, 3.14.8]
17+
# Pin to 3.14.8 and 3.15.0 to workaround AB#4147280
18+
python-version: [3.11, 3.15.0]
1919
runs-on: ${{ matrix.os }}
2020
steps:
2121
- name: Check out repo

‎.github/workflows/run_unit_tests.yml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [windows-latest, ubuntu-latest, macos-latest]
16-
# Pin to 3.14.8 to workaround AB#4147280
17-
python-version: [3.9, '3.10', 3.11, 3.12, 3.13, 3.14.8, 3.14t, pypy3.11]
16+
# Pin to 3.14.8 and 3.15.0 to workaround AB#4147280
17+
python-version: [3.11, 3.12, 3.13, 3.14.8, 3.14t, 3.15.0, 3.15t, pypy3.11]
1818
# Fail-fast skews the pass/fail ratio and seems to make pytest produce
1919
# incomplete JUnit XML results.
2020
fail-fast: false
@@ -38,7 +38,12 @@ jobs:
3838
- name: Install nitypes
3939
run: poetry install -v
4040
- name: Display installed dependency versions
41-
run: poetry run pip list
41+
run: |
42+
# Use importlib instead of assuming that the project venv contains an up-to-date pip.
43+
import importlib.metadata
44+
for dist in sorted(importlib.metadata.Distribution.discover(), key=lambda d: d.name):
45+
print(f"{dist.name}: {dist.version}")
46+
shell: poetry run python {0}
4247
- name: Run unit/acceptance/doc tests and code coverage
4348
run: poetry run pytest -v --cov=nitypes --junitxml=test_results/nitypes-${{ matrix.os }}-py${{ matrix.python-version }}.xml
4449
- name: Run benchmarks

‎.github/workflows/run_unit_tests_oldest_deps.yml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [windows-latest, ubuntu-latest]
16-
python-version: [3.9]
16+
python-version: [3.11]
1717
# Fail-fast skews the pass/fail ratio and seems to make pytest produce
1818
# incomplete JUnit XML results.
1919
fail-fast: false
@@ -47,7 +47,12 @@ jobs:
4747
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
4848
run: poetry install -v
4949
- name: Display installed dependency versions
50-
run: poetry run pip list
50+
run: |
51+
# Use importlib instead of assuming that the project venv contains an up-to-date pip.
52+
import importlib.metadata
53+
for dist in sorted(importlib.metadata.Distribution.discover(), key=lambda d: d.name):
54+
print(f"{dist.name}: {dist.version}")
55+
shell: poetry run python {0}
5156
- name: Run unit tests and code coverage
5257
# Skip test___pickled_value___unpickle___is_compatible because this test's pickle data was saved with NumPy 2.x and cannot be loaded in NumPy 1.x.
5358
run: poetry run pytest ./tests/unit -v --cov=nitypes --junitxml=test_results/nitypes-oldest-deps-${{ matrix.os }}-py${{ matrix.python-version }}.xml -k "not test___pickled_value___unpickle___is_compatible"

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ See the [API Reference](https://nitypes.readthedocs.io/).
4747

4848
## Python Version Support
4949

50-
`nitypes` supports CPython 3.9+ and PyPy3.
50+
`nitypes` supports CPython 3.11+ and PyPy3.
5151

5252
# Installation
5353

‎docs/intro.inc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Operating System Support
2121
Python Version Support
2222
----------------------
2323

24-
``nitypes`` supports CPython 3.9+ and PyPy3.
24+
``nitypes`` supports CPython 3.11+ and PyPy3.
2525

2626
Installation
2727
------------

‎poetry.lock‎

Lines changed: 155 additions & 948 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@ classifiers = [
1313
"Operating System :: Microsoft :: Windows",
1414
"Operating System :: POSIX",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.9",
17-
"Programming Language :: Python :: 3.10",
1816
"Programming Language :: Python :: 3.11",
1917
"Programming Language :: Python :: 3.12",
2018
"Programming Language :: Python :: 3.13",
2119
"Programming Language :: Python :: 3.14",
20+
"Programming Language :: Python :: 3.15",
2221
"Programming Language :: Python :: Implementation :: CPython",
2322
"Programming Language :: Python :: Implementation :: PyPy",
2423
]
2524
dynamic = ["dependencies"]
2625
readme = "README.md"
2726
authors = [{name = "NI", email = "opensource@ni.com"}]
2827
maintainers = [{name = "Brad Keryan", email = "brad.keryan@ni.com"}]
29-
requires-python = '>=3.9,<4.0'
28+
requires-python = '>=3.11,<4.0'
3029

3130
[project.urls]
3231
repository = "https://github.com/ni/nitypes-python"
@@ -37,9 +36,10 @@ packages = [{ include = "nitypes", from = "src" }]
3736
requires-poetry = '>=2.1,<3.0'
3837

3938
[tool.poetry.dependencies]
40-
# NumPy 2.0.x is the last version that supports Python 3.9, but it crashes with Python 3.13.
39+
# NumPy 1.23.2 is the first version with binary wheels for Python 3.11. NumPy
40+
# 1.22 crashes on Python 3.11 and NumPy 2.0.x crashes on Python 3.13.
4141
numpy = [
42-
{ version = ">=1.22", python = ">=3.9,<3.13" },
42+
{ version = ">=1.23.2", python = ">=3.11,<3.13" },
4343
{ version = ">=2.1", python = "^3.13" }
4444
]
4545
hightime = { version = ">=0.2.2", allow-prereleases = true }
@@ -48,10 +48,10 @@ typing-extensions = ">=4.13.2"
4848
[tool.poetry.group.dev.dependencies]
4949
# Specify additional NumPy version constraints to speed up locking and test with binary wheels that support PyPy.
5050
numpy = [
51-
{ version = ">=1.22", python = ">=3.9,<3.12", markers = "implementation_name != 'pypy'" },
51+
{ version = ">=1.23.2", python = ">=3.11,<3.12", markers = "implementation_name != 'pypy'" },
5252
{ version = ">=1.26", python = ">=3.12,<3.13", markers = "implementation_name != 'pypy'" },
53-
{ version = ">=2.1", python = "^3.13", markers = "implementation_name != 'pypy'" },
54-
{ version = ">=2.1", python = ">=3.10,<3.11", markers = "implementation_name == 'pypy'" },
53+
{ version = ">=2.1", python = ">=3.13,<3.15", markers = "implementation_name != 'pypy'" },
54+
{ version = ">=2.5.1", python = "^3.15", markers = "implementation_name != 'pypy'" },
5555
{ version = ">=2.3", python = "^3.11", markers = "implementation_name == 'pypy'" },
5656
]
5757

@@ -76,12 +76,7 @@ tzlocal = ">=5.0"
7676
optional = true
7777

7878
[tool.poetry.group.docs.dependencies]
79-
# The latest Sphinx requires a recent Python version.
80-
Sphinx = [
81-
{ version = ">=7.4", python = ">=3.9,<3.10" },
82-
{ version = ">=8.1", python = ">=3.10,<3.11" },
83-
{ version = ">=8.2", python = "^3.11" },
84-
]
79+
Sphinx = ">=8.2"
8580
sphinx-rtd-theme = ">=1.0.0"
8681
sphinx-autoapi = ">=1.8.4"
8782
m2r2 = ">=0.3.2"

‎tests/unit/complex/test_conversion.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,15 @@ def test___arrays_with_static_shape___convert_complex___preserves_static_and_run
155155
value_out_3d = convert_complex(np.complex64, value_in_3d)
156156

157157
assert_type(value_out_1d, np.ndarray[tuple[int], np.dtype[np.complex128]])
158-
assert_type(value_out_2d, np.ndarray[tuple[int, int], np.dtype[ComplexInt32Base]])
159-
assert_type(value_out_3d, np.ndarray[tuple[int, int, int], np.dtype[np.complex64]])
158+
# With NumPy 2.5.4, Pyright infers np.ndarray[tuple[Literal[4], Literal[5]], ...]
159+
assert_type(
160+
value_out_2d, # pyright: ignore[reportAssertTypeFailure]
161+
np.ndarray[tuple[int, int], np.dtype[ComplexInt32Base]],
162+
)
163+
assert_type(
164+
value_out_3d, # pyright: ignore[reportAssertTypeFailure]
165+
np.ndarray[tuple[int, int, int], np.dtype[np.complex64]],
166+
)
160167
assert isinstance(value_out_1d, np.ndarray) and value_out_1d.shape == (3,)
161168
assert isinstance(value_out_2d, np.ndarray) and value_out_2d.shape == (4, 5)
162169
assert isinstance(value_out_3d, np.ndarray) and value_out_3d.shape == (6, 7, 8)

0 commit comments

Comments
 (0)