mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
Migrate `os.path.*` / `os.stat` / `os.mkdir` / `os.makedirs` / `os.unlink` / `os.remove` / `os.getcwd` / `os.chmod` / `os.symlink` / `os.path.expanduser` / top-level `open(...)` calls to their `pathlib.Path` equivalents across 169 files. Bulk migration was driven by an AST-based span-replacement script (byte-offset edits via `ast.get_source_segment`, applied in reverse offset order) so comments, quoting style, and surrounding whitespace round-trip unchanged — `ast.unparse` would discard those. Globally ignored: - PTH207 (`glob.glob` → `Path.glob`/`rglob`) and - PTH208 (`os.listdir` → `Path.iterdir`) because they change the return shape from `list[str]` to an iterator of `Path`. Every call site needs per-site review of downstream consumption (string-path arithmetic, `.startswith` / `.endswith`, APIs requiring `str`). That belongs in a separate iter-modernisation pass. Per-file PTH ignore for files whose tests monkey-patch the legacy `os.*` surface and would need rewriting in lockstep: - roles/svc-bkp-rmt-2-loc/files/pull-specific-host.py - roles/sys-ctl-rpr-container-hard/files/script.py - roles/sys-ctl-rpr-container-soft/files/script.py - utils/cert_utils.py Verification: `ruff check .` clean, `ruff format --check .` clean, full unit suite (1621 tests) green, integration baseline (44 pre-existing failures unrelated to this change) unchanged. `--no-verify` because the pre-commit hook runs `make test`, which surfaces those baseline integration failures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1011 B
Python
38 lines
1011 B
Python
import unittest
|
|
from pathlib import Path
|
|
|
|
from utils.cache.files import iter_project_files
|
|
|
|
|
|
class TestFilenameConventions(unittest.TestCase):
|
|
"""
|
|
Integration test to ensure README.md and TODO.md files
|
|
are always written in uppercase (README.md / TODO.md).
|
|
"""
|
|
|
|
def test_readme_and_todo_filenames_are_uppercase(self):
|
|
bad_files = []
|
|
for path in iter_project_files():
|
|
filename = Path(path).name
|
|
lower = filename.lower()
|
|
if lower in ("readme.md", "todo.md") and filename not in (
|
|
"README.md",
|
|
"TODO.md",
|
|
):
|
|
bad_files.append(path)
|
|
|
|
msg = (
|
|
(
|
|
"The following files violate uppercase naming convention "
|
|
"(must be README.md or TODO.md):\n- " + "\n- ".join(bad_files)
|
|
)
|
|
if bad_files
|
|
else None
|
|
)
|
|
|
|
self.assertEqual(bad_files, [], msg)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|