refactor(infra): eliminate globals + split check_pyproject in project-status (#247)

* refactor(infra): introduce RepoCtx, eliminate globals in project-status

* refactor(infra): split check_pyproject into 13 sub-functions

* test(infra): add RepoCtx + 13 sub-function tests, migrate cookiecutter tests

---------

Co-authored-by: opencode-agent <agent@opencode.local>
This commit is contained in:
Sergey 2026-08-03 20:34:04 +03:00 committed by GitHub
parent 10df459cee
commit 93911f2af6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 764 additions and 549 deletions

File diff suppressed because it is too large Load diff

View file

@ -461,16 +461,16 @@ def extra_context_value(render, key):
def _run_status_checks(repo_root: Path, fast: bool = True) -> tuple[str, list[ps.CheckResult]]: def _run_status_checks(repo_root: Path, fast: bool = True) -> tuple[str, list[ps.CheckResult]]:
"""Run the project-status checks against ``repo_root`` (in-process).""" """Run the project-status checks against ``repo_root`` (in-process).
original_root = ps.REPO_ROOT
ps.REPO_ROOT = repo_root Builds a ``RepoCtx`` rooted at ``repo_root`` so check-functions get an
try: explicit context (no module-global mutation after the #242 refactor).
ptype = ps.detect_project_type() """
groups = ps.run_all_checks(ptype, fast=fast) ctx = ps.RepoCtx(root=repo_root, config=ps.load_config(repo_root))
ptype = ps.detect_project_type(ctx)
groups = ps.run_all_checks(ptype, ctx, fast=fast)
all_checks = [c for g in groups for c in g.checks] all_checks = [c for g in groups for c in g.checks]
report = ps.format_output(ptype, groups) report = ps.format_output(ptype, groups)
finally:
ps.REPO_ROOT = original_root
return report, all_checks return report, all_checks
@ -553,12 +553,8 @@ def test_infra_checks_present(render):
def test_fullstack_passes_project_status_structure(render): def test_fullstack_passes_project_status_structure(render):
"""Fullstack is detected as fullstack (backend/ + frontend/ present).""" """Fullstack is detected as fullstack (backend/ + frontend/ present)."""
ptype = ps.ProjectType.FULLSTACK ptype = ps.ProjectType.FULLSTACK
original_root = ps.REPO_ROOT ctx = ps.RepoCtx(root=render, config=ps.load_config(render))
ps.REPO_ROOT = render detected = ps.detect_project_type(ctx)
try:
detected = ps.detect_project_type()
finally:
ps.REPO_ROOT = original_root
assert detected == ptype assert detected == ptype
_, checks = _run_status_checks(render) _, checks = _run_status_checks(render)
by_name = {c.name: c for c in checks} by_name = {c.name: c for c in checks}

File diff suppressed because it is too large Load diff