Skip to content

Commit a3acbc8

Browse files
leliaclaude
andcommitted
Make every __version__ consumer quote-agnostic
`ruff format` normalises string quotes to double, so `__version__` in socketsecurity/__init__.py went from single to double quotes. Five places parsed or rewrote that line assuming single quotes: - version-check.yml stripped only `'`, so it read the version as `"2.7.2"` (quotes included) and failed to parse it. This is what broke on the PR. - build_container.sh and build_container_flexible.sh would have produced a Docker tag containing literal quote characters. - deploy-test-pypi.sh both read the version and rewrote it with a sed that matched single quotes only, so the rewrite would silently no-op. - .hooks/sync_version.py read either quote style but always wrote single quotes, so it and the formatter would have rewritten the same line back and forth on every commit. Readers now strip both quote characters and the hook writes double quotes to match the formatter. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ea36905 commit a3acbc8

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

.github/workflows/version-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ jobs:
3232
pip install packaging
3333
3434
# Get version from current PR
35-
PR_VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
35+
PR_VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "\"'")
3636
echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV
3737
3838
# Get version from main branch
39-
MAIN_VERSION=$(git show origin/main:socketsecurity/__init__.py | grep -o "__version__.*" | awk '{print $3}' | tr -d "'")
39+
MAIN_VERSION=$(git show origin/main:socketsecurity/__init__.py | grep -o "__version__.*" | awk '{print $3}' | tr -d "\"'")
4040
echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV
4141
4242
export PR_VERSION

.hooks/sync_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def inject_version(version: str):
105105

106106
# Update __init__.py
107107
init_content = INIT_FILE.read_text()
108-
new_init_content = VERSION_PATTERN.sub(f"__version__ = '{version}'", init_content)
108+
new_init_content = VERSION_PATTERN.sub(f'__version__ = "{version}"', init_content)
109109
INIT_FILE.write_text(new_init_content)
110110

111111
# Update pyproject.toml

scripts/build_container.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
2+
VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "\"'")
33
ENABLE_PYPI_BUILD=$1
44
STABLE_VERSION=$2
55

scripts/build_container_flexible.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
2+
VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "\"'")
33
ENABLE_PYPI_BUILD=$1
44
STABLE_VERSION=$2
55
GO_VERSION=${GO_VERSION:-"1.21"}

scripts/deploy-test-pypi.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Get version from __init__.py
66
INIT_FILE="socketsecurity/__init__.py"
7-
ORIGINAL_VERSION=$(grep -o "__version__.*" $INIT_FILE | awk '{print $3}' | tr -d "'")
7+
ORIGINAL_VERSION=$(grep -o "__version__.*" $INIT_FILE | awk '{print $3}' | tr -d "\"'")
88
BACKUP_FILE="${INIT_FILE}.bak"
99

1010
# Get existing versions from TestPyPI
@@ -37,7 +37,7 @@ echo "Deploying version ${VERSION} to Test PyPI"
3737
cp $INIT_FILE $BACKUP_FILE
3838

3939
# Update version in __init__.py
40-
sed -i.tmp "s/__version__ = '${ORIGINAL_VERSION}'/__version__ = '${VERSION}'/" $INIT_FILE
40+
sed -i.tmp -E "s/__version__ = ['\"]${ORIGINAL_VERSION}['\"]/__version__ = \"${VERSION}\"/" $INIT_FILE
4141
rm "${INIT_FILE}.tmp"
4242

4343
# Build and upload to test PyPI

0 commit comments

Comments
 (0)