Skip to content

Commit 80b7162

Browse files
authored
Use Python 3.12 for internal code (#2222)
* Use Python 3.12 for internal code * Add changelog entry
1 parent e570478 commit 80b7162

File tree

15 files changed

+33
-39
lines changed

15 files changed

+33
-39
lines changed

.github/actions/create-dev-env/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
- name: Set Up Python 🐍
88
uses: actions/setup-python@v5
99
with:
10-
python-version: "3.12"
10+
python-version: 3.12
1111

1212
- name: Install Dev Dependencies 📦
1313
run: |

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Set Up Python 🐍
2222
uses: actions/setup-python@v5
2323
with:
24-
python-version: 3.x
24+
python-version: 3.12
2525

2626
- name: Install pre-commit 📦
2727
run: |

.github/workflows/sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Set Up Python 🐍
3939
uses: actions/setup-python@v5
4040
with:
41-
python-version: 3.9
41+
python-version: 3.12
4242

4343
- name: Install Doc Dependencies 📦
4444
run: |

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
rev: v3.19.1
1818
hooks:
1919
- id: pyupgrade
20-
args: [--py39-plus]
20+
args: [--py312-plus]
2121

2222
# Automatically sort python imports
2323
- repo: https://github.com/PyCQA/isort
@@ -31,7 +31,7 @@ repos:
3131
rev: 25.1.0
3232
hooks:
3333
- id: black
34-
args: [--target-version=py39]
34+
args: [--target-version=py312]
3535

3636
# Check python code static typing
3737
- repo: https://github.com/pre-commit/mirrors-mypy
@@ -141,10 +141,10 @@ repos:
141141
rev: 1.9.1
142142
hooks:
143143
- id: nbqa-pyupgrade
144-
args: [--py39-plus]
144+
args: [--py312-plus]
145145
- id: nbqa-isort
146146
- id: nbqa-black
147-
args: [--target-version=py39]
147+
args: [--target-version=py312]
148148
- id: nbqa-flake8
149149

150150
# Run black on python code blocks in documentation files.
@@ -156,7 +156,7 @@ repos:
156156
# the python code blocks include jupyter-specific additions such as % or !
157157
# See https://github.com/adamchainz/blacken-docs/issues/127 for an upstream
158158
# feature request about this.
159-
args: [--target-version=py39, --skip-errors]
159+
args: [--target-version=py312, --skip-errors]
160160

161161
# pre-commit.ci config reference: https://pre-commit.ci/#configuration
162162
ci:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Affected: all images.
1111
- **Non-breaking:** don't create extra free space in runners for cuda images ([#2218](https://github.com/jupyter/docker-stacks/pull/2218)).
1212
- **Non-breaking:** revert "Pin some packages to fix `r-notebook` and `datascience-notebook` under aarch64" ([#2220](https://github.com/jupyter/docker-stacks/pull/2220)).
1313
- **Non-breaking:** Simplify and improve `test_packages.py` ([#2219](https://github.com/jupyter/docker-stacks/pull/2219)).
14+
- **Non-breaking:** Use Python 3.12 for internal code ([#2222](https://github.com/jupyter/docker-stacks/pull/2222)).
1415

1516
## 2025-02-17
1617

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# We use mypy as part of pre-commit checks
99

1010
[mypy]
11-
python_version = 3.9
11+
python_version = 3.12
1212
follow_imports = error
1313
strict = True
1414
no_incremental = True

tagging/docker_runner.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Distributed under the terms of the Modified BSD License.
33
import logging
44
from types import TracebackType
5-
from typing import Optional
65

76
import docker
87
from docker.models.containers import Container
@@ -17,7 +16,7 @@ def __init__(
1716
docker_client: docker.DockerClient = docker.from_env(),
1817
command: str = "sleep infinity",
1918
):
20-
self.container: Optional[Container] = None
19+
self.container: Container | None = None
2120
self.image_name: str = image_name
2221
self.command: str = command
2322
self.docker_client: docker.DockerClient = docker_client
@@ -34,9 +33,9 @@ def __enter__(self) -> Container:
3433

3534
def __exit__(
3635
self,
37-
exc_type: Optional[type[BaseException]],
38-
exc_val: Optional[BaseException],
39-
exc_tb: Optional[TracebackType],
36+
exc_type: type[BaseException] | None,
37+
exc_val: BaseException | None,
38+
exc_tb: TracebackType | None,
4039
) -> None:
4140
assert self.container is not None
4241
LOGGER.info(f"Removing container {self.container.name} ...")

tagging/get_taggers_and_manifests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3-
from typing import Optional
43

54
from tagging.images_hierarchy import ALL_IMAGES
65
from tagging.manifests import ManifestInterface
76
from tagging.taggers import TaggerInterface
87

98

109
def get_taggers_and_manifests(
11-
short_image_name: Optional[str],
10+
short_image_name: str | None,
1211
) -> tuple[list[TaggerInterface], list[ManifestInterface]]:
1312
if short_image_name is None:
1413
return [[], []] # type: ignore

tagging/images_hierarchy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
33
from dataclasses import dataclass, field
4-
from typing import Optional
54

65
from tagging.manifests import (
76
AptPackagesManifest,
@@ -32,7 +31,7 @@
3231

3332
@dataclass
3433
class ImageDescription:
35-
parent_image: Optional[str]
34+
parent_image: str | None
3635
taggers: list[TaggerInterface] = field(default_factory=list)
3736
manifests: list[ManifestInterface] = field(default_factory=list)
3837

tests/base-notebook/test_healthcheck.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Distributed under the terms of the Modified BSD License.
33
import logging
44
import time
5-
from typing import Optional
65

76
import pytest # type: ignore
87

@@ -56,9 +55,9 @@
5655
)
5756
def test_healthy(
5857
container: TrackedContainer,
59-
env: Optional[list[str]],
60-
cmd: Optional[list[str]],
61-
user: Optional[str],
58+
env: list[str] | None,
59+
cmd: list[str] | None,
60+
user: str | None,
6261
) -> None:
6362
running_container = container.run_detached(
6463
tty=True,
@@ -104,9 +103,9 @@ def test_healthy(
104103
)
105104
def test_healthy_with_proxy(
106105
container: TrackedContainer,
107-
env: Optional[list[str]],
108-
cmd: Optional[list[str]],
109-
user: Optional[str],
106+
env: list[str] | None,
107+
cmd: list[str] | None,
108+
user: str | None,
110109
) -> None:
111110
running_container = container.run_detached(
112111
tty=True,
@@ -142,8 +141,8 @@ def test_healthy_with_proxy(
142141
)
143142
def test_not_healthy(
144143
container: TrackedContainer,
145-
env: Optional[list[str]],
146-
cmd: Optional[list[str]],
144+
env: list[str] | None,
145+
cmd: list[str] | None,
147146
) -> None:
148147
running_container = container.run_detached(
149148
tty=True,

0 commit comments

Comments
 (0)