ci: address PR 30 Codex feedback #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Address PR 30 Codex feedback | |
| on: | |
| push: | |
| branches: | |
| - docs/add-int-float-bool-chapter | |
| permissions: | |
| contents: write | |
| jobs: | |
| address-feedback: | |
| if: "!contains(github.event.head_commit.message, '[pr30-codex-addressed]')" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: docs/add-int-float-bool-chapter | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.14' | |
| - name: Qualify true division behavior | |
| shell: python | |
| run: | | |
| from pathlib import Path | |
| replacements = { | |
| Path('strings-and-numbers/03-int-float-and-bool/README.md'): [ | |
| ( | |
| 'Even when both operands are integers, `/` produces a floating-point result.', | |
| 'Even when both operands are integers, `/` normally produces a floating-point result when the quotient is representable as a `float`. If the integer quotient is too large to be represented as a `float`, true division raises `OverflowError` instead.' | |
| ), | |
| ( | |
| 'If the mathematical quotient is whole, the result is still a `float` when `/` is used.', | |
| 'When the quotient is representable as a `float`, a mathematically whole quotient still has type `float` when `/` is used.' | |
| ), | |
| ], | |
| Path('strings-and-numbers/03-int-float-and-bool/README.pt-BR.md'): [ | |
| ( | |
| 'Mesmo quando os dois operandos são inteiros, `/` produz um resultado de ponto flutuante.', | |
| 'Mesmo quando os dois operandos são inteiros, `/` normalmente produz um resultado de ponto flutuante quando o quociente pode ser representado como `float`. Se o quociente inteiro for grande demais para ser representado como `float`, a divisão verdadeira gera `OverflowError`.' | |
| ), | |
| ( | |
| 'Se o quociente matemático for inteiro, o resultado ainda será um `float` quando `/` for utilizado.', | |
| 'Quando o quociente pode ser representado como `float`, um quociente matematicamente inteiro ainda tem tipo `float` quando `/` é utilizado.' | |
| ), | |
| ], | |
| Path('strings-and-numbers/03-int-float-and-bool/README.es.md'): [ | |
| ( | |
| 'Incluso cuando ambos operandos son enteros, `/` produce un resultado de punto flotante.', | |
| 'Incluso cuando ambos operandos son enteros, `/` normalmente produce un resultado de punto flotante cuando el cociente puede representarse como `float`. Si el cociente entero es demasiado grande para representarse como `float`, la división verdadera genera `OverflowError`.' | |
| ), | |
| ( | |
| 'Si el cociente matemático es entero, el resultado sigue siendo un `float` cuando se usa `/`.', | |
| 'Cuando el cociente puede representarse como `float`, un cociente matemáticamente entero sigue teniendo tipo `float` cuando se usa `/`.' | |
| ), | |
| ], | |
| } | |
| for path, pairs in replacements.items(): | |
| text = path.read_text(encoding='utf-8') | |
| for old, new in pairs: | |
| if text.count(old) != 1: | |
| raise SystemExit(f'Expected exactly one occurrence in {path}: {old!r}') | |
| text = text.replace(old, new) | |
| path.write_text(text, encoding='utf-8') | |
| - name: Validate multilingual technical blocks | |
| shell: python | |
| run: | | |
| import re | |
| from pathlib import Path | |
| paths = [ | |
| Path('strings-and-numbers/03-int-float-and-bool/README.md'), | |
| Path('strings-and-numbers/03-int-float-and-bool/README.pt-BR.md'), | |
| Path('strings-and-numbers/03-int-float-and-bool/README.es.md'), | |
| ] | |
| blocks = [] | |
| for path in paths: | |
| text = path.read_text(encoding='utf-8') | |
| extracted = re.findall(r'```(?:python|text|bash)\n.*?```', text, flags=re.S) | |
| blocks.append(extracted) | |
| if not (blocks[0] == blocks[1] == blocks[2]): | |
| raise SystemExit('Localized technical blocks are not byte-aligned') | |
| print(f'Validated {len(blocks[0])} aligned technical blocks.') | |
| - name: Validate repository | |
| run: | | |
| python -m compileall . | |
| python scripts/run_examples.py | |
| python scripts/check_internal_links.py | |
| python scripts/validate_repository_structure.py | |
| - name: Commit fixes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add strings-and-numbers/03-int-float-and-bool/README.md \ | |
| strings-and-numbers/03-int-float-and-bool/README.pt-BR.md \ | |
| strings-and-numbers/03-int-float-and-bool/README.es.md | |
| git diff --cached --quiet && exit 0 | |
| git commit -m "docs: qualify large-integer true division [pr30-codex-addressed]" | |
| git push origin HEAD:docs/add-int-float-bool-chapter |