Skip to content

Commit 7eb6030

Browse files
authored
upgrade to python3.12.4 (#16105)
* upgrade to python3.12.4 * lint * take correct tag from hub.docker.com * update linter to py312 syntax * re-compile all deps
1 parent 280d3b4 commit 7eb6030

File tree

18 files changed

+57
-195
lines changed

18 files changed

+57
-195
lines changed

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.11.9
1+
3.12.4

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN NODE_ENV=production npm run build
3636

3737

3838
# We'll build a light-weight layer along the way with just docs stuff
39-
FROM python:3.11.9-slim-bookworm as docs
39+
FROM python:3.12.4-slim-bookworm as docs
4040

4141
# By default, Docker has special steps to avoid keeping APT caches in the layers, which
4242
# is good, but in our case, we're going to mount a special cache volume (kept between
@@ -105,7 +105,7 @@ USER docs
105105

106106
# Now we're going to build our actual application, but not the actual production
107107
# image that it gets deployed into.
108-
FROM python:3.11.9-slim-bookworm as build
108+
FROM python:3.12.4-slim-bookworm as build
109109

110110
# Define whether we're building a production or a development image. This will
111111
# generally be used to control whether or not we install our development and
@@ -189,7 +189,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
189189

190190
# Now we're going to build our actual application image, which will eventually
191191
# pull in the static files that were built above.
192-
FROM python:3.11.9-slim-bookworm
192+
FROM python:3.12.4-slim-bookworm
193193

194194
# Setup some basic environment variables that are ~never going to change.
195195
ENV PYTHONUNBUFFERED 1

bin/lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export LANG="${ENCODING:-en_US.UTF-8}"
1111
set -x
1212

1313
# Actually run our tests.
14-
find . -name '*.py' -exec python -m pyupgrade --py311-plus {} +
14+
find . -name '*.py' -exec python -m pyupgrade --py312-plus {} +
1515
python -m flake8 .
1616
python -m black --check --diff *.py warehouse/ tests/
1717
python -m isort --check *.py warehouse/ tests/

requirements/deploy.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
55
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/deploy.txt requirements/deploy.in
@@ -215,3 +215,9 @@ zipp==3.19.2 \
215215
--hash=sha256:bf1dcf6450f873a13e952a29504887c89e6de7506209e5b1bcc3460135d4de19 \
216216
--hash=sha256:f091755f667055f2d02b32c53771a7a6c8b47e1fdbc4b72a8b9072b3eef8015c
217217
# via importlib-metadata
218+
219+
# The following packages are considered to be unsafe in a requirements file:
220+
setuptools==70.0.0 \
221+
--hash=sha256:54faa7f2e8d2d11bcd2c07bed282eef1046b5c080d1c32add737d7b5817b1ad4 \
222+
--hash=sha256:f211a66637b8fa059bb28183da127d4e86396c991a942b028c6650d4319c3fd0
223+
# via ddtrace

requirements/docs-blog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
55
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/docs-blog.txt requirements/docs-blog.in

requirements/docs-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
55
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/docs-dev.txt requirements/docs-dev.in

requirements/docs-user.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
55
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/docs-user.txt requirements/docs-user.in

requirements/lint.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
55
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/lint.txt requirements/lint.in
@@ -429,7 +429,6 @@ typing-extensions==4.12.1 \
429429
--hash=sha256:6024b58b69089e5a89c347397254e35f1bf02a907728ec7fee9bf0fe837d203a \
430430
--hash=sha256:915f5e35ff76f56588223f15fdd5938f9a1cf9195c0de25130c627e4d597f6d1
431431
# via
432-
# boto3-stubs
433432
# celery-types
434433
# mypy
435434
zope-event==5.0 \

requirements/main.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ b2sdk
66
Babel
77
bcrypt
88
boto3
9-
celery[sqs]>=5.2.2,<5.3.2
9+
celery[sqs]>=5.3.5,<5.4
1010
celery-redbeat
1111
certifi
1212
click
@@ -25,7 +25,7 @@ html5lib
2525
humanize
2626
itsdangerous
2727
Jinja2>=2.8
28-
kombu[sqs]<5.3.2 # https://github.com/jazzband/pip-tools/issues/1577
28+
kombu[sqs]>=5.3.5,<5.4 # https://github.com/jazzband/pip-tools/issues/1577
2929
limits
3030
linehaul
3131
lxml

requirements/main.txt

Lines changed: 7 additions & 150 deletions
Large diffs are not rendered by default.

requirements/tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
55
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/tests.txt requirements/tests.in

tests/unit/accounts/test_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_too_many_emails_added(self, pyramid_request):
104104
assert resp.detail == (
105105
"Too many emails have been added to this account without verifying "
106106
"them. Check your inbox and follow the verification links. (IP: "
107-
f"{ pyramid_request.remote_addr })"
107+
f"{pyramid_request.remote_addr})"
108108
)
109109
assert dict(resp.headers).get("Retry-After") == "600"
110110

@@ -117,7 +117,7 @@ def test_too_many_password_reset_requests(self, pyramid_request):
117117
assert resp.detail == (
118118
"Too many password resets have been requested for this account without "
119119
"completing them. Check your inbox and follow the verification links. (IP: "
120-
f"{ pyramid_request.remote_addr })"
120+
f"{pyramid_request.remote_addr})"
121121
)
122122
assert dict(resp.headers).get("Retry-After") == "600"
123123

tests/unit/email/test_init.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3694,7 +3694,7 @@ def test_collaborator_removed_email(self, db_request, pyramid_config, monkeypatc
36943694
]
36953695
assert send_email.delay.calls == [
36963696
pretend.call(
3697-
f"{ removed_user.name } <{ removed_user.primary_email.email }>",
3697+
f"{removed_user.name} <{removed_user.primary_email.email}>",
36983698
{
36993699
"subject": "Email Subject",
37003700
"body_text": "Email Body",
@@ -3715,7 +3715,7 @@ def test_collaborator_removed_email(self, db_request, pyramid_config, monkeypatc
37153715
},
37163716
),
37173717
pretend.call(
3718-
f"{ submitter_user.name } <{ submitter_user.primary_email.email }>",
3718+
f"{submitter_user.name} <{submitter_user.primary_email.email}>",
37193719
{
37203720
"subject": "Email Subject",
37213721
"body_text": "Email Body",
@@ -3789,7 +3789,7 @@ def test_removed_as_collaborator_email(
37893789
assert db_request.task.calls == [pretend.call(send_email)]
37903790
assert send_email.delay.calls == [
37913791
pretend.call(
3792-
f"{ removed_user.name } <{ removed_user.primary_email.email }>",
3792+
f"{removed_user.name} <{removed_user.primary_email.email}>",
37933793
{
37943794
"subject": "Email Subject",
37953795
"body_text": "Email Body",
@@ -3872,7 +3872,7 @@ def test_role_changed_email(self, db_request, pyramid_config, monkeypatch):
38723872
]
38733873
assert send_email.delay.calls == [
38743874
pretend.call(
3875-
f"{ changed_user.name } <{ changed_user.primary_email.email }>",
3875+
f"{changed_user.name} <{changed_user.primary_email.email}>",
38763876
{
38773877
"subject": "Email Subject",
38783878
"body_text": "Email Body",
@@ -3893,7 +3893,7 @@ def test_role_changed_email(self, db_request, pyramid_config, monkeypatch):
38933893
},
38943894
),
38953895
pretend.call(
3896-
f"{ submitter_user.name } <{ submitter_user.primary_email.email }>",
3896+
f"{submitter_user.name} <{submitter_user.primary_email.email}>",
38973897
{
38983898
"subject": "Email Subject",
38993899
"body_text": "Email Body",
@@ -3971,7 +3971,7 @@ def test_role_changed_as_collaborator_email(
39713971
assert db_request.task.calls == [pretend.call(send_email)]
39723972
assert send_email.delay.calls == [
39733973
pretend.call(
3974-
f"{ changed_user.name } <{ changed_user.primary_email.email }>",
3974+
f"{changed_user.name} <{changed_user.primary_email.email}>",
39753975
{
39763976
"subject": "Email Subject",
39773977
"body_text": "Email Body",
@@ -5535,15 +5535,15 @@ def test_recovery_code_emails(
55355535
primary_email=pretend.stub(email="email@example.com", verified=True),
55365536
)
55375537
subject_renderer = pyramid_config.testing_add_renderer(
5538-
f"email/{ template_name }/subject.txt"
5538+
f"email/{template_name}/subject.txt"
55395539
)
55405540
subject_renderer.string_response = "Email Subject"
55415541
body_renderer = pyramid_config.testing_add_renderer(
5542-
f"email/{ template_name }/body.txt"
5542+
f"email/{template_name}/body.txt"
55435543
)
55445544
body_renderer.string_response = "Email Body"
55455545
html_renderer = pyramid_config.testing_add_renderer(
5546-
f"email/{ template_name }/body.html"
5546+
f"email/{template_name}/body.html"
55475547
)
55485548
html_renderer.string_response = "Email HTML Body"
55495549

@@ -5616,15 +5616,15 @@ def test_pending_trusted_publisher_emails(
56165616
primary_email=pretend.stub(email="email@example.com", verified=True),
56175617
)
56185618
subject_renderer = pyramid_config.testing_add_renderer(
5619-
f"email/{ template_name }/subject.txt"
5619+
f"email/{template_name}/subject.txt"
56205620
)
56215621
subject_renderer.string_response = "Email Subject"
56225622
body_renderer = pyramid_config.testing_add_renderer(
5623-
f"email/{ template_name }/body.txt"
5623+
f"email/{template_name}/body.txt"
56245624
)
56255625
body_renderer.string_response = "Email Body"
56265626
html_renderer = pyramid_config.testing_add_renderer(
5627-
f"email/{ template_name }/body.html"
5627+
f"email/{template_name}/body.html"
56285628
)
56295629
html_renderer.string_response = "Email HTML Body"
56305630

@@ -5700,15 +5700,15 @@ def test_trusted_publisher_emails(
57005700
primary_email=pretend.stub(email="email@example.com", verified=True),
57015701
)
57025702
subject_renderer = pyramid_config.testing_add_renderer(
5703-
f"email/{ template_name }/subject.txt"
5703+
f"email/{template_name}/subject.txt"
57045704
)
57055705
subject_renderer.string_response = "Email Subject"
57065706
body_renderer = pyramid_config.testing_add_renderer(
5707-
f"email/{ template_name }/body.txt"
5707+
f"email/{template_name}/body.txt"
57085708
)
57095709
body_renderer.string_response = "Email Body"
57105710
html_renderer = pyramid_config.testing_add_renderer(
5711-
f"email/{ template_name }/body.html"
5711+
f"email/{template_name}/body.html"
57125712
)
57135713
html_renderer.string_response = "Email HTML Body"
57145714

@@ -5804,15 +5804,15 @@ def test_api_token_warning_with_trusted_publisher_emails(
58045804
),
58055805
)
58065806
subject_renderer = pyramid_config.testing_add_renderer(
5807-
f"email/{ template_name }/subject.txt"
5807+
f"email/{template_name}/subject.txt"
58085808
)
58095809
subject_renderer.string_response = "Email Subject"
58105810
body_renderer = pyramid_config.testing_add_renderer(
5811-
f"email/{ template_name }/body.txt"
5811+
f"email/{template_name}/body.txt"
58125812
)
58135813
body_renderer.string_response = "Email Body"
58145814
html_renderer = pyramid_config.testing_add_renderer(
5815-
f"email/{ template_name }/body.html"
5815+
f"email/{template_name}/body.html"
58165816
)
58175817
html_renderer.string_response = "Email HTML Body"
58185818

tests/unit/email/test_services.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def test_last_sent(self, db_session):
347347
for address in [to, "somebody_else@example.com"]:
348348
for subject in [subject, "I do not care about this"]:
349349
sender.send(
350-
f"Foobar <{ address }>",
350+
f"Foobar <{address}>",
351351
EmailMessage(
352352
subject=subject, body_text="This is a plain text body"
353353
),
@@ -362,7 +362,7 @@ def test_last_sent(self, db_session):
362362
aws_client, sender="DevPyPI <noreply@example.com>", db=db_session
363363
)
364364
sender.send(
365-
f"Foobar <{ to }>",
365+
f"Foobar <{to}>",
366366
EmailMessage(subject=subject, body_text="This is a plain text body"),
367367
)
368368

tests/unit/sponsors/test_models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
def test_sponsor_color_logo_img_tag(db_request):
1717
sponsor = SponsorFactory.create()
1818
expected = (
19-
f'<img src="{ sponsor.color_logo_url }"'
20-
+ f' alt="{ sponsor.name }" loading="lazy">'
19+
f'<img src="{sponsor.color_logo_url}"'
20+
+ f' alt="{sponsor.name}" loading="lazy">'
2121
)
2222
assert sponsor.color_logo_img == expected
2323

2424

2525
def test_sponsor_white_logo_img_tag(db_request):
2626
sponsor = SponsorFactory.create()
2727
expected = (
28-
f'<img class="sponsors__image" src="{ sponsor.white_logo_url }"'
29-
+ f' alt="{ sponsor.name }" loading="lazy">'
28+
f'<img class="sponsors__image" src="{sponsor.white_logo_url}"'
29+
+ f' alt="{sponsor.name}" loading="lazy">'
3030
)
3131
assert sponsor.white_logo_img == expected
3232

warehouse/accounts/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class RecoveryCodeValueMixin:
120120
wtforms.validators.InputRequired(),
121121
PreventNullBytesValidator(),
122122
wtforms.validators.Regexp(
123-
rf"^ *([0-9a-f] *){{{2*RECOVERY_CODE_BYTES}}}$",
123+
rf"^ *([0-9a-f] *){{{2 * RECOVERY_CODE_BYTES}}}$",
124124
message=_(
125125
"Recovery Codes must be ${recovery_code_length} characters.",
126126
mapping={"recovery_code_length": 2 * RECOVERY_CODE_BYTES},

warehouse/oidc/forms/activestate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ def _activestate_gql_api_call(
7272
)
7373
if response.status_code == 404:
7474
sentry_sdk.capture_message(
75-
f"Unexpected {response.status_code } error "
75+
f"Unexpected {response.status_code} error "
7676
f"from ActiveState API: {response.content!r}"
7777
)
7878
raise wtforms.validators.ValidationError(
7979
_("Unexpected error from ActiveState. Try again in a few minutes")
8080
)
8181
elif response.status_code >= 400:
8282
sentry_sdk.capture_message(
83-
f"Unexpected {response.status_code } error "
83+
f"Unexpected {response.status_code} error "
8484
f"from ActiveState API: {response.content!r}"
8585
)
8686
raise wtforms.validators.ValidationError(

warehouse/sponsors/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ class Sponsor(db.Model):
4848

4949
@property
5050
def color_logo_img(self):
51-
return f'<img src="{ self.color_logo_url }" alt="{ self.name }" loading="lazy">'
51+
return f'<img src="{self.color_logo_url}" alt="{self.name}" loading="lazy">'
5252

5353
@property
5454
def white_logo_img(self):
5555
if not self.white_logo_url:
5656
return ""
5757
return (
5858
'<img class="sponsors__image" '
59-
+ f'src="{ self.white_logo_url }" alt="{ self.name }" loading="lazy">'
59+
+ f'src="{self.white_logo_url}" alt="{self.name}" loading="lazy">'
6060
)
6161

6262
@property

0 commit comments

Comments
 (0)