Skip to content

Commit 9155ab1

Browse files
authored
Merge branch 'main' into pep-841
2 parents 0aac5ae + b53285d commit 9155ab1

29 files changed

Lines changed: 2316 additions & 490 deletions

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,11 @@ peps/pep-0832.rst @brettcannon
711711
peps/pep-0833.rst @dstufft
712712
peps/pep-0835.rst @ilevkivskyi
713713
peps/pep-0836.rst @savannahostrowski @Fidget-Spinner @brandtbucher
714+
peps/pep-0837.rst @serhiy-storchaka
715+
peps/pep-0838.rst @AlexWaygood
714716
peps/pep-0840.rst @jeremyhylton @gvanrossum
715717
peps/pep-0841.rst @corona10 @sobolevn
718+
peps/pep-0842.rst @ZeroIntensity
716719
# ...
717720
peps/pep-2026.rst @hugovk
718721
# ...

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
21+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2222
with:
2323
persist-credentials: false
2424

2525
- name: Run pre-commit hooks
26-
uses: j178/prek-action@e98a699c41eb69ab013a45817a0406469a748f8d # v2.0.5
26+
uses: j178/prek-action@5337cb91e0fa35a7ff31b9ca345126d8bbbcdf16 # v2.0.6
2727

2828
- name: Check spelling
29-
uses: j178/prek-action@e98a699c41eb69ab013a45817a0406469a748f8d #v2.0.5
29+
uses: j178/prek-action@5337cb91e0fa35a7ff31b9ca345126d8bbbcdf16 #v2.0.6
3030
continue-on-error: true
3131
with:
3232
extra_args: --all-files --hook-stage manual codespell

.github/workflows/render.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ jobs:
2727

2828
steps:
2929
- name: Checkout
30-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1
3131
with:
3232
fetch-depth: 0 # fetch all history so that last modified date-times are accurate
3333
persist-credentials: false
3434

3535
- name: Set up Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
36+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
3737
with:
3838
python-version: ${{ matrix.python-version }}
3939
cache: pip

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ jobs:
4242
- "ubuntu-latest"
4343

4444
steps:
45-
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
45+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4646
with:
4747
persist-credentials: false
4848

4949
- name: Set up Python ${{ matrix.python-version }}
50-
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
50+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
5151
with:
5252
python-version: ${{ matrix.python-version }}
5353
allow-prereleases: true
5454

5555
- name: Install uv
56-
uses: hynek/setup-cached-uv@4300ec2180bc77d705e626a34e381b81a4772c51 # v2.5.0
56+
uses: hynek/setup-cached-uv@34e35d30f1ebc7421a5cc733bca38dcc62603960 # v2.6.0
5757
with:
5858
cache-dependency-path: |
5959
requirements.txt

pep_sphinx_extensions/pep_theme/templates/page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<h1 data-pagefind-ignore>Python Enhancement Proposals</h1>
3838
<ul class="breadcrumbs">
3939
<li><a href="https://www.python.org/" title="The Python Programming Language">Python</a> &raquo; </li>
40-
<li><a href="{{ pathto("pep-0000") }}">PEP Index</a> &raquo; </li>
40+
<li><a href="{{ pathto('', resource=True) }}" title="Python Enhancement Proposals (PEPs)">PEP Index</a> &raquo; </li>
4141
<li>{{ title.split("–")[0].strip() }}</li>
4242
</ul>
4343
<button id="colour-scheme-cycler" onClick="setColourScheme(nextColourScheme())">

pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,45 @@ def write_peps_json(peps: list[parser.PEP], path: Path) -> None:
6060
Path(path, "api", "peps.json").write_text(json_peps, encoding="utf-8")
6161

6262

63+
def build_release_peps(peps: list[parser.PEP]) -> dict[str, int]:
64+
"""Map each Python version to its release-schedule PEP number.
65+
66+
Handles release PEPs that cover multiple versions jointly
67+
(e.g. "2.6, 3.0"), so individual versions also resolve.
68+
"""
69+
release_peps: dict[str, int] = {}
70+
71+
for pep in peps:
72+
if pep.python_version and "release" in pep.topic:
73+
for version in map(str.strip, pep.python_version.split(",")):
74+
release_peps[version] = pep.number
75+
76+
return release_peps
77+
78+
6379
def create_pep_zero(app: Sphinx, env: BuildEnvironment, docnames: list[str]) -> None:
6480
peps = _parse_peps(Path(app.srcdir))
6581

66-
numerical_index_text = writer.PEPZeroWriter().write_numerical_index(peps)
82+
release_peps = build_release_peps(peps)
83+
84+
numerical_index_text = writer.PEPZeroWriter(
85+
release_peps
86+
).write_numerical_index(peps)
6787
subindices.update_sphinx("numerical", numerical_index_text, docnames, env)
6888

69-
pep0_text = writer.PEPZeroWriter().write_pep0(peps, builder=env.settings["builder"])
89+
pep0_text = writer.PEPZeroWriter(
90+
release_peps
91+
).write_pep0(peps, builder=env.settings["builder"])
7092
pep0_path = subindices.update_sphinx("pep-0000", pep0_text, docnames, env)
7193
peps.append(parser.PEP(pep0_path))
7294

73-
subindices.generate_subindices(SUBINDICES_BY_TOPIC, peps, docnames, env)
95+
subindices.generate_subindices(
96+
SUBINDICES_BY_TOPIC,
97+
peps,
98+
release_peps,
99+
docnames,
100+
env,
101+
)
74102

75103
write_peps_json(peps, Path(app.outdir))
76104

pep_sphinx_extensions/pep_zero_generator/subindices.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def update_sphinx(filename: str, text: str, docnames: list[str], env: BuildEnvir
3535
def generate_subindices(
3636
subindices: dict[str, str],
3737
peps: list[PEP],
38+
release_peps: dict[str, int],
3839
docnames: list[str],
3940
env: BuildEnvironment,
4041
) -> None:
@@ -58,8 +59,11 @@ def generate_subindices(
5859
5960
{additional_description}
6061
"""
61-
subindex_text = writer.PEPZeroWriter().write_pep0(
62-
filtered_peps, header, subindex_intro, is_pep0=False,
62+
subindex_text = writer.PEPZeroWriter(release_peps).write_pep0(
63+
filtered_peps,
64+
header,
65+
subindex_intro,
66+
is_pep0=False,
6367
)
6468
update_sphinx(f"topic/{subindex}", subindex_text, docnames, env)
6569

pep_sphinx_extensions/pep_zero_generator/writer.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ class PEPZeroWriter:
5959
801: "Warsaw",
6060
}
6161

62-
def __init__(self):
62+
def __init__(self, release_peps: dict[str, int] | None = None):
6363
self.output: list[str] = []
64+
self.release_peps = release_peps or {}
6465

6566
def emit_text(self, content: str) -> None:
6667
# Appends content argument to the output list
@@ -87,7 +88,17 @@ def emit_pep_row(
8788
self.emit_text(f" - :pep:`{title.replace('`', '')} <{number}>`")
8889
self.emit_text(f" - {authors}")
8990
if python_version is not None:
90-
self.emit_text(f" - {python_version}")
91+
linked_versions = []
92+
93+
for version in map(str.strip, python_version.split(",")):
94+
release_pep = self.release_peps.get(version)
95+
96+
if release_pep is not None:
97+
linked_versions.append(f":pep:`{version} <{release_pep}>`")
98+
else:
99+
linked_versions.append(version)
100+
101+
self.emit_text(f" - {', '.join(linked_versions)}")
91102

92103
def emit_column_headers(self, *, include_version=True) -> None:
93104
"""Output the column headers for the PEP indices."""

pep_sphinx_extensions/tests/pep_zero_generator/test_pep_index_generator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ def test_create_pep_json():
99
out = pep_index_generator.create_pep_json(peps)
1010

1111
assert '"url": "https://peps.python.org/pep-0008/"' in out
12+
13+
14+
def test_build_release_peps_links_individual_versions_from_joint_release_pep():
15+
peps = [
16+
parser.PEP(PEP_ROOT / "pep-0361.rst"), # "2.6, 3.0" joint release PEP
17+
]
18+
19+
release_peps = pep_index_generator.build_release_peps(peps)
20+
21+
assert release_peps == {"2.6": 361, "3.0": 361}

pep_sphinx_extensions/tests/pep_zero_generator/test_writer.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,42 @@ def test_sort_authors():
8686

8787
# Assert
8888
assert out == ["Aardvark, Alfred", "lowercase, laurence", "Zebra, Zoë"]
89+
90+
91+
@pytest.mark.parametrize(
92+
("python_version", "expected"),
93+
[
94+
("3.14", " - :pep:`3.14 <745>`"),
95+
(
96+
"2.4, 2.5, 2.6",
97+
" - :pep:`2.4 <320>`, :pep:`2.5 <356>`, :pep:`2.6 <361>`",
98+
),
99+
("2.4, 2.9", " - :pep:`2.4 <320>`, 2.9"),
100+
("1.5.2", " - 1.5.2"),
101+
("", " - "),
102+
],
103+
)
104+
def test_emit_pep_row_links_python_version_to_release_pep(
105+
python_version,
106+
expected,
107+
):
108+
# Arrange
109+
release_peps = {
110+
"2.4": 320,
111+
"2.5": 356,
112+
"2.6": 361,
113+
"3.14": 745,
114+
}
115+
pep0_writer = writer.PEPZeroWriter(release_peps=release_peps)
116+
117+
# Act
118+
pep0_writer.emit_pep_row(
119+
shorthand="Active",
120+
number=999,
121+
title="Test PEP",
122+
authors="Test Author",
123+
python_version=python_version,
124+
)
125+
126+
# Assert
127+
assert expected in pep0_writer.output

0 commit comments

Comments
 (0)