Skip to content

Commit

Permalink
chore: update Python 3.12.6 (#16700)
Browse files Browse the repository at this point in the history
* chore: update Python 3.12.6

Refs: https://www.python.org/downloads/release/python-3126/

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

* chore: remove unreachable condition

Now that Python validates the addresses more strictly, we won't hit the
condition any longer.

If we wish to preserve this condition, we could also pass `strict=False`
to `getaddresses()`, but that seems to be counter to our desire of
having a valid email address.

Refs: python/cpython#123766

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

* test: refactor test case to parametrize

Extract test cases from inline to make it clearer which permutations are
being tested.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>

---------

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman authored Sep 13, 2024
1 parent 6b5f6bf commit 55ccaf7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12.4
3.12.6
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"
commands:
- ./bin/rtd-docs
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN NODE_ENV=production npm run build


# We'll build a light-weight layer along the way with just docs stuff
FROM python:3.12.4-slim-bookworm AS docs
FROM python:3.12.6-slim-bookworm AS docs

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

# Now we're going to build our actual application, but not the actual production
# image that it gets deployed into.
FROM python:3.12.4-slim-bookworm AS build
FROM python:3.12.6-slim-bookworm AS build

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

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

# Setup some basic environment variables that are ~never going to change.
ENV PYTHONUNBUFFERED 1
Expand Down
56 changes: 30 additions & 26 deletions tests/unit/rss/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import datetime

import pretend
import pytest

from warehouse.rss import views as rss

Expand Down Expand Up @@ -102,36 +103,39 @@ def test_rss_project_releases(db_request):
assert db_request.response.content_type == "text/xml"


def test_format_author(db_request):
@pytest.mark.parametrize(
("author_email", "expected"),
[
(None, None),
("", None),
("UNKNOWN", None),
("noreply@pypi.org, UNKNOWN", None),
("noreply@pypi.org", "noreply@pypi.org"),
("No Reply <noreply@pypi.org>", "noreply@pypi.org"),
(
(
# simple, no spaces
"noreply@pypi.org,"
# space after
"noreply@pypi.org ,"
# space before, incl realname
" No Reply <noreply@pypi.org>,"
# two spaces before, angle brackets
" <noreply@pypi.org>"
),
", ".join(["noreply@pypi.org"] * 4),
),
],
)
def test_format_author(db_request, author_email, expected):
db_request.find_service = pretend.call_recorder(
lambda *args, **kwargs: pretend.stub(
enabled=False, csp_policy=pretend.stub(), merge=lambda _: None
)
)

db_request.session = pretend.stub()

project = ProjectFactory.create()
release = ReleaseFactory.create(project=project)

release.author_email = "noreply@pypi.org"
assert rss._format_author(release) == release.author_email

release.author_email = "No Reply <noreply@pypi.org>"
assert rss._format_author(release) == "noreply@pypi.org"

for invalid in (None, "", "UNKNOWN", "noreply@pypi.org, UNKNOWN"):
release.author_email = invalid
assert rss._format_author(release) is None

release.author_email = (
# simple, no spaces
"noreply@pypi.org,"
# space after
"noreply@pypi.org ,"
# space before, incl realname
" No Reply <noreply@pypi.org>,"
# two spaces before, angle brackets
" <noreply@pypi.org>"
)
assert rss._format_author(release) == ", ".join(["noreply@pypi.org"] * 4)
release = ReleaseFactory.create()

release.author_email = author_email
assert rss._format_author(release) == expected
2 changes: 0 additions & 2 deletions warehouse/rss/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def _format_author(release):
return None
author_emails.append(author_email)

if not author_emails:
return None
return ", ".join(author_emails)


Expand Down

0 comments on commit 55ccaf7

Please sign in to comment.