Skip to content

Commit 525c3a8

Browse files
authored
BREAK: drop support for Python 3.9 (#323)
* DX: define Poe the Poet `lab` job for Jupyter lab * MAINT: upgrade Jupyter notebook kernels
1 parent aa90974 commit 525c3a8

22 files changed

+255
-650
lines changed

docs/_extend_docstrings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
import inspect
1010
import logging
1111
import textwrap
12-
from typing import Callable
12+
from typing import TYPE_CHECKING
1313

1414
import qrules
1515

16+
if TYPE_CHECKING:
17+
from collections.abc import Callable
18+
1619
logging.getLogger().setLevel(logging.ERROR)
1720

1821

docs/usage.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
"name": "python",
278278
"nbconvert_exporter": "python",
279279
"pygments_lexer": "ipython3",
280-
"version": "3.9.18"
280+
"version": "3.13.8"
281281
}
282282
},
283283
"nbformat": 4,

docs/usage/conservation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@
417417
"name": "python",
418418
"nbconvert_exporter": "python",
419419
"pygments_lexer": "ipython3",
420-
"version": "3.11.7"
420+
"version": "3.13.8"
421421
}
422422
},
423423
"nbformat": 4,

docs/usage/custom-topology.ipynb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@
290290
"display_name": "Python 3 (ipykernel)",
291291
"language": "python",
292292
"name": "python3"
293+
},
294+
"language_info": {
295+
"codemirror_mode": {
296+
"name": "ipython",
297+
"version": 3
298+
},
299+
"file_extension": ".py",
300+
"mimetype": "text/x-python",
301+
"name": "python",
302+
"nbconvert_exporter": "python",
303+
"pygments_lexer": "ipython3",
304+
"version": "3.13.8"
293305
}
294306
},
295307
"nbformat": 4,

docs/usage/ls-coupling.ipynb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,18 @@
336336
"display_name": "Python 3 (ipykernel)",
337337
"language": "python",
338338
"name": "python3"
339+
},
340+
"language_info": {
341+
"codemirror_mode": {
342+
"name": "ipython",
343+
"version": 3
344+
},
345+
"file_extension": ".py",
346+
"mimetype": "text/x-python",
347+
"name": "python",
348+
"nbconvert_exporter": "python",
349+
"pygments_lexer": "ipython3",
350+
"version": "3.13.8"
339351
}
340352
},
341353
"nbformat": 4,

docs/usage/particle.ipynb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,18 @@
467467
"display_name": "Python 3 (ipykernel)",
468468
"language": "python",
469469
"name": "python3"
470+
},
471+
"language_info": {
472+
"codemirror_mode": {
473+
"name": "ipython",
474+
"version": 3
475+
},
476+
"file_extension": ".py",
477+
"mimetype": "text/x-python",
478+
"name": "python",
479+
"nbconvert_exporter": "python",
480+
"pygments_lexer": "ipython3",
481+
"version": "3.13.8"
470482
}
471483
},
472484
"nbformat": 4,

docs/usage/reaction.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@
620620
"name": "python",
621621
"nbconvert_exporter": "python",
622622
"pygments_lexer": "ipython3",
623-
"version": "3.12.11"
623+
"version": "3.13.8"
624624
}
625625
},
626626
"nbformat": 4,

docs/usage/visualize.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@
792792
"name": "python",
793793
"nbconvert_exporter": "python",
794794
"pygments_lexer": "ipython3",
795-
"version": "3.12.8"
795+
"version": "3.13.8"
796796
}
797797
},
798798
"nbformat": 4,

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ classifiers = [
2020
"Programming Language :: Python :: 3.12",
2121
"Programming Language :: Python :: 3.13",
2222
"Programming Language :: Python :: 3.14",
23-
"Programming Language :: Python :: 3.9",
2423
"Programming Language :: Python",
2524
"Topic :: Scientific/Engineering :: Physics",
2625
"Topic :: Scientific/Engineering",
@@ -49,7 +48,7 @@ keywords = [
4948
license = {file = "LICENSE"}
5049
maintainers = [{email = "[email protected]"}]
5150
name = "qrules"
52-
requires-python = ">=3.9"
51+
requires-python = ">=3.10"
5352

5453
[project.optional-dependencies]
5554
viz = ["graphviz"]
@@ -303,6 +302,11 @@ env = {EXECUTE_NB = "yes"}
303302
help = "Set up a server to directly preview changes to the HTML pages with cached notebook execution"
304303
sequence = ["doclive"]
305304

305+
[tool.poe.tasks.lab]
306+
args = [{name = "paths", default = "", positional = true}]
307+
cmd = "jupyter lab ${paths}"
308+
help = "Run Jupyter Lab"
309+
306310
[tool.poe.tasks.linkcheck]
307311
cmd = """
308312
uv run --group doc --isolated --no-dev \

src/qrules/argument_handling.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import inspect
1111
from fractions import Fraction
12-
from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar, Union
12+
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Union
1313

1414
import attrs
1515

@@ -21,11 +21,10 @@
2121
from qrules.quantum_numbers import EdgeQuantumNumber, NodeQuantumNumber, Parity
2222

2323
if TYPE_CHECKING:
24-
from collections.abc import Sequence
24+
from collections.abc import Callable, Sequence
2525

26-
Scalar = Union[int, float, Fraction]
27-
28-
Rule = Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]
26+
Scalar = int | float | Fraction
27+
Rule = GraphElementRule | EdgeQNConservationRule | ConservationRule
2928
"""Any type of rule"""
3029

3130
_ElementType = TypeVar("_ElementType")
@@ -95,7 +94,7 @@ def wrapper(states_list: Sequence[Any]) -> bool:
9594

9695
def _check_all_arguments(checks: list[Callable]) -> Callable[..., bool]:
9796
def wrapper(*args: Any) -> bool:
98-
return all(check(arg) for check, arg in zip(checks, args))
97+
return all(check(arg) for check, arg in zip(checks, args, strict=False))
9998

10099
return wrapper
101100

@@ -171,7 +170,7 @@ def wrapper(states_list: Sequence[Any]) -> list[Any]:
171170

172171
def _build_all_arguments(checks: list[Callable]) -> Callable:
173172
def wrapper(*args: Any) -> list[Any]:
174-
return [check(arg) for check, arg in zip(checks, args) if arg]
173+
return [check(arg) for check, arg in zip(checks, args, strict=False) if arg]
175174

176175
return wrapper
177176

0 commit comments

Comments
 (0)