Skip to content

Rename Every Python File to the Fleet's snake_case Names - #537

Merged
ptr727 merged 5 commits into
developfrom
refactor/shared-sibling-loader
Oct 26, 2026
Merged

ptr727 merged 5 commits into
developfrom
refactor/shared-sibling-loader

Conversation

@ptr727

@ptr727 ptr727 commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

#532 asked for one loader for hyphenated sibling scripts. The fleet's answer is that no loader is needed. The hub's CODESTYLE.md "Script and Utility File Names" makes a Python file lowercase snake_case, because a hyphenated module cannot be named in an import. So this renames every hyphenated .py in the repository, and siblings import by name.

  • Names. Every hyphenated .py under checks/, scripts/, and capture/ is renamed to snake_case. A gate, a script that exits non-zero on a finding, takes the _gate suffix, the way the hub's own host_gate.py and repo_gate.py do. So check-csp.py becomes csp_gate.py, fuzz-media-parsers.py becomes media_parser_fuzz_gate.py, and normalize-media.py becomes normalize_media.py. Tests follow their module, so test_check_csp.py becomes test_csp_gate.py. check-live-urls.sh keeps its hyphen, since the shell rule wants one.
  • Imports. The by-path importlib loaders are gone, all of them, and so is the checks/sibling.py this pull request first added. A gate imports its sibling by name. A test, or a script reaching the other declared directory, inserts that directory on sys.path and imports the module, the pattern the hub's tests use. Every test file therefore runs directly again, which Copilot found the first version broke.
  • Type checks. Each directory's pyproject.toml ignores missing imports for the one module it reads from the other directory, since neither directory's mypy run reads the other's tree.
  • References. Workflows, deploy/make-release.sh, .vscode/tasks.json, the validate action, the browser check's container path, and every doc name the new files. Markdown link labels that spelled an old file stem now spell the new one. reports/ and content/ are left as written, since they record what was true when they were written.
  • capture/ is one-shot tooling outside the declared Python directories. Only its file names and the references to them change, and one comment is reflowed for the prose gate.

Fixes #532, which closes when the promotion carrying this reaches main.

Verification

  • checks/, run as CI runs it: ruff, ruff format, and mypy are clean, and coverage run -m unittest discover -s tests passes 201 tests.
  • scripts/, run as CI runs it in a fresh .venv from requirements.txt: ruff, ruff format, and mypy are clean, and pytest passes 29 tests.
  • Every checks/tests/*.py file passes when run directly as python3 checks/tests/<file>.py.
  • Every renamed script runs by path from the repository root, the way make-release.sh, the validate action, and the tasks run it. All of them keep mode 755 and their shebangs. The capture/ files compile.
  • The hub prose gate reports nothing beyond comment-added, which the comments label clears.
  • The local strict review ran on the first version and on this one. On this one, round 1 raised a false reason in the new checks/ mypy comment, and a reflowed comment the prose gate would refuse. Both are fixed in f577785, together with a test patch that sharing one module object made redundant.

Pre-existing findings, not filed

  • CONTENT.md:79, :81, :127, ENVIRONMENT.md:5, GOVERNANCE.md:273, OPERATIONS.md:217, capture/README.md:60, :64, :72, capture/run-wp2hugo.sh:6, checks/media_metadata_gate.py:24: pre-existing. Sentences over 25 words, on lines the rename touched without lengthening them.

Pre-existing findings, filed

Dropped findings

  • scripts/normalize_media.py:418, style: a scratch-directory prefix still spells normalize-media-. It names no file.
  • CONTENT.md, README.md, deploy/README.md, checks/README.md, style: some link labels, such as [text-pii] and [checks-csp], never spelled a whole file stem and keep their names.

🤖 Generated with Claude Code

ptr727 and others added 2 commits October 25, 2026 16:50
checks/sibling.py holds the one loader. The three helper copies in
check-csp.py, fuzz-media-parsers.py, and test_check_media_metadata.py,
and the four inline copies at the top of the other check tests, now
call it by name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Oct 25, 2026
Copilot AI lite review requested due to automatic review settings October 25, 2026 23:57
@ptr727

ptr727 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head a8f5b45448b4d355c4f15c1558a5ce716ac5ca2f, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d7e0e733-2fd3-4eab-9f68-8b09cdf1f548
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@34d728e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
checks/csp_gate.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #537   +/-   ##
==========================================
  Coverage           ?   54.07%           
==========================================
  Files              ?       12           
  Lines              ?     3390           
  Branches           ?        0           
==========================================
  Hits               ?     1833           
  Misses             ?     1557           
  Partials           ?        0           
Flag Coverage Δ
python-3.13 54.07% <91.66%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Direct execution of the retained test entry points fails because sibling is not importable from the repository root.

No open issues 🎉

What changed in this PR

This pull request consolidates duplicated hyphenated-sibling script loading logic in checks/ into a shared sibling.load helper.

Changes:

  • Adds the typed shared loader in checks/sibling.py.
  • Updates check scripts and tests to use the shared helper.
  • Adds coverage for loading hyphenated scripts.
  • Requires a fix so the affected tests also work when executed directly from the repository root.
File Description
checks/​tests/​test_sibling.py Tests loading a constructed hyphenated script; direct standalone execution currently cannot import sibling.
checks/​tests/​test_check_text_pii.py Uses the shared loader for the PII gate.
checks/​tests/​test_check_media_metadata.py Uses the shared loader for media-related modules.
checks/​tests/​test_check_github_env.py Uses the shared loader for the environment gate.
checks/​tests/​test_check_csp.py Uses the shared loader for the CSP gate.
checks/​tests/​test_check_csp_browser.py Uses the shared loader for the browser CSP gate.
checks/​sibling.py Adds the shared path-based module loader.
checks/​fuzz-media-parsers.py Replaces local loading logic with sibling.load.
checks/​check-csp.py Replaces its local sibling loader with sibling.load.

Review effort: Lite

ptr727 and others added 3 commits October 25, 2026 17:24
A hyphenated module cannot be named in an import, which is why the
tooling needed a by-path loader at all. Every .py under checks/,
scripts/, and capture/ now takes a snake_case name, and a gate takes
the _gate suffix, so siblings import by name and checks/sibling.py
goes. A test puts its directory on sys.path and imports the module,
the way the hub's tests do, so running a test file directly works
again. Each directory's mypy config ignores the one module it imports
from the other declared directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727 ptr727 changed the title Load Each checks/ Sibling Script From One Shared Helper Rename Every Python File to the Fleet's snake_case Names Oct 26, 2026
@ptr727

ptr727 commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head f57778530aeb7887eb65b4f0373518ae84bc28b6, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727

ptr727 commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Fixed in d073e66, with f577785 on top. The review of a8f5b45 found that running a test file directly failed, because sibling was not importable from checks/tests/. Following the fleet's file-name rule removes the cause. Every hyphenated .py is renamed to snake_case, siblings import by name, and each test inserts its directory on sys.path before importing its module, the pattern the hub's tests use. checks/sibling.py is gone. Every checks/tests/*.py now passes when run directly as python3 checks/tests/<file>.py.

@ptr727
ptr727 merged commit 9bd721a into develop Oct 26, 2026
12 checks passed
@ptr727
ptr727 deleted the refactor/shared-sibling-loader branch October 26, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants