Skip to content

feat: add lint_repo script to detect and lint repository languages - #139

Merged
dclong merged 1 commit into
mainfrom
push-qxnxzozysywn
Sep 27, 2026
Merged

dclong merged 1 commit into
mainfrom
push-qxnxzozysywn

Conversation

@dclong

@dclong dclong commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • feat: add lint_repo script to detect and lint repository languages

Changed files

Added

  • github_rest_api/scripts/lint_repo.py (+556/-0)
  • tests/test_lint_repo.py (+608/-0)
    Modified
  • pyproject.toml (+1/-0)

Commits

  • 815e332 feat: add lint_repo script to detect and lint repository languages

@dclong

dclong commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Claude finished @dclong's task in 2m 52s —— View job


Claude's Review of PR #139

  • Gather context (PR diff, changed files, CLAUDE.md)
  • Review lint_repo.py and test_lint_repo.py manually (the /code-review:code-review skill wasn't invokable in this sandboxed environment, and most Bash commands beyond read-only git diff required approval that wasn't available, so I could not execute pytest/ruff/ty here — review is based on careful manual reading of the diff)
  • Post review feedback
  • Decide on auto-merge eligibility

Summary

This adds github_rest_api/scripts/lint_repo.py, a well-structured script that detects a repo's languages from git-tracked files and runs the matching lint checks (mirroring lint.yaml's detect + per-language jobs). It's registered as a uv script entry point in pyproject.toml, and comes with a thorough test suite (tests/test_lint_repo.py, 60+ tests) covering detection, check construction, missing-tool handling, fail-fast semantics, and the CLI.

Findings

Minor (non-blocking): summary count double-counts non-fatal failures as "passed"

In run_checks (github_rest_api/scripts/lint_repo.py:383-430), a check that fails but has fatal=False (e.g. markdown: lychee) is neither appended to failed nor skipped:

elif check.fatal:
    failed.append(check.name)
    print(f"FAIL: {check.name}", flush=True)
    ...
else:
    print(f"WARN (non-fatal): {check.name}", flush=True)

But the final tally is passed = len(ran) - len(failed) - len(skipped), so a non-fatally-failed check gets counted as "passed" in the printed Summary: N/M passed line even though it actually failed (just non-fatally). This doesn't affect the returned failed-checks list or the process exit code — only the human-readable summary text is misleading. Worth a follow-up but not a blocker.

Fix this →

Other observations (no action needed)

  • list_tracked_files correctly relies on dulwich's Index.__iter__ yielding tracked path keys, matches the project's dulwich-first convention from CLAUDE.md, and handles non-UTF-8 filenames via surrogateescape (covered by a dedicated test).
  • The late-binding closure pitfall in build_python_scripts_checks (looping to build a run=lambda cwd, s=script: ... per script) is correctly avoided via the s=script default argument.
  • Missing-tool handling is centralized in run_check so both command- and run-based checks get --on-missing-tool support for free, and a run callable is confirmed (by test) to never execute when a required tool is missing.
  • pyproject.toml's new scripts.lint_repo entry is correctly placed in alphabetical order.

No correctness bugs found that would affect actual lint outcomes or exit codes. The one issue above is cosmetic/logging-only.

AUTO_MERGE_APPROVED

@dclong
dclong merged commit 12e7769 into main Sep 27, 2026
22 checks passed
@dclong
dclong deleted the push-qxnxzozysywn branch September 28, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant