Skip to content

Commit 3776c5a

Browse files
authored
Unwind pre-tomllib workaround (#7121)
1 parent adae4a5 commit 3776c5a

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ jobs:
5151
- name: "Check Release Notes"
5252
run: |
5353
set -ex
54-
python scripts/extract-release-notes.py --target-git-version
54+
scripts/extract-release-notes.py --target-git-version
5555
shell: bash
5656
- name: "Produce Release Notes"
5757
run: |
5858
set -ex
5959
set -o pipefail
60-
python ./scripts/extract-release-notes.py --target-git-version --describe-path-changes "./samples/constitution" | tee rel-notes.md
60+
./scripts/extract-release-notes.py --target-git-version --describe-path-changes "./samples/constitution" | tee rel-notes.md
6161
- name: "Upload Release Notes"
6262
uses: actions/upload-artifact@v4
6363
with:

scripts/ci-checks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ endgroup
6868

6969
group "Release notes"
7070
if [ $FIX -ne 0 ]; then
71-
python3 "$SCRIPT_DIR"/extract-release-notes.py -f
71+
"$SCRIPT_DIR"/extract-release-notes.py -f
7272
else
73-
python3 "$SCRIPT_DIR"/extract-release-notes.py
73+
"$SCRIPT_DIR"/extract-release-notes.py
7474
fi
7575
endgroup
7676

scripts/extract-release-notes.py

100644100755
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
#!/usr/bin/env python3
12
# Copyright (c) Microsoft Corporation. All rights reserved.
23
# Licensed under the Apache 2.0 License.
34

45
import argparse
56
import re
67
import sys
78
import subprocess
9+
import tomllib
810

911

1012
def main():
@@ -53,15 +55,11 @@ def main():
5355
release_notes = {}
5456
links_found = []
5557

56-
# Check that pyproject.toml is up to date
57-
# Once we have upgraded to Python 3.11, we can use tomllib to parse pyproject.toml
58-
pyproject_version = None
59-
with open("python/pyproject.toml") as pyproject:
60-
for line in pyproject:
61-
if line.startswith("version"):
62-
_, version = line.split("=")
63-
pyproject_version = version.strip().strip('"')
64-
assert pyproject_version is not None, "Could not find version in pyproject.toml"
58+
version_in_pyproject = None
59+
with open("python/pyproject.toml", "rb") as pyproject:
60+
config = tomllib.load(pyproject)
61+
version_in_pyproject = config.get("project", {}).get("version")
62+
assert version_in_pyproject is not None, "Could not find version in pyproject.toml"
6563

6664
# Parse file, bucketing lines into each version's release notes
6765
current_release_notes = None
@@ -72,8 +70,8 @@ def main():
7270
current_release_notes = []
7371
if not release_notes:
7472
assert (
75-
log_version == pyproject_version
76-
), f"First version in CHANGELOG ({log_version}) must match version in pyproject.toml ({pyproject_version})"
73+
log_version == version_in_pyproject
74+
), f"First version in CHANGELOG ({log_version}) must match version in pyproject.toml ({version_in_pyproject})"
7775
release_notes[log_version] = current_release_notes
7876
elif match := link_definition.match(line):
7977
link_version = match.group(1)

0 commit comments

Comments
 (0)