Skip to content

Nerves board: flag library config keys no library code reads (#174) - #175

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/nerves-unused-keys
Sep 27, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/nerves-unused-keys

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Extends the Nerves board so it flags library config keys that no library code reads (closes #174).

scripts/board.py now walks every library package's .py files (and autonerves/) with an AST scan for config lookups: literal conf.instance[...] chains (multi-line, .get("k")), non-literal subscripts treated as wildcards, sections bound to a local and indexed later (closures included), and should_output("name"). Every library settings key is then classed used / section-read / unused against the reads of the whole stack. Priors are exempt, and the scan is skipped if any library is missing.

Where it shows up: an "unused" chip on the key, per-file counts on the repo page, a "Possibly unused config keys" section on the index (grouped by library, with GitHub links), the class in board.json and the key index, and one info item per library in state.json. It is never yellow. SOURCES gains each library's package dir, and the workflow's sparse checkout now also fetches <package>/**/*.py.

Scan results (used / section-read / unused)

Library used section-read unused
PyAutoFit 58 45 8
PyAutoArray 43 84 1
PyAutoGalaxy 51 190 1
PyAutoLens 17 50 58
PyAutoCTI 26 46 8

False-positive review list (needs human review, may be read dynamically)

These PyAutoFit general.yaml keys are flagged unused. They may be read through a dynamic path the AST scan cannot see, so do not delete them on this evidence alone:

  • output.log_level
  • output.log_to_file
  • output.log_file
  • output.search_internal
  • profiling.repeats

Also: PyAutoLens has a dead 57-key DynestyStatic / DynestyDynamic block in non_linear.yaml, which accounts for almost all of Lens's 58 unused keys. It is a cleanup candidate for a follow-up, not something this PR changes.

API Changes

None to the autonerves package. This is internal to the board script and workflow. The only visible schema change is additive: board.json / the key index gain a per-key usage class, and state.json gains one info item per library.
See full details below.

Test Plan

  • python -m pytest test_autonerves -q: 206 passed (worktree, before push)
  • nerves_board.yml renders the "Possibly unused config keys" section after merge (dispatch after merge)

Heart YELLOW acknowledged by human (reasons: manifest drift in the hub organism blurb (7), organism-map blocks (1) and workspace checkouts (1); release validation stale for PyAutoFit/Array/Galaxy/Lens). None of these involve this repo.

Full API Changes (for automation & release notes)

Added

  • scripts/board.py: AST config-read scanner over library packages; per-key class used / section-read / unused
  • board.json / key index: per-key usage class field
  • state.json: one info item per library summarising possibly-unused keys
  • .github/workflows/nerves_board.yml: sparse checkout adds <package>/**/*.py

Changed Behaviour

  • Board index gains a "Possibly unused config keys" section; repo pages gain per-file counts

Closes #174

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

scripts/board.py scans every library package's .py (and autonerves/) with
an AST walk for config lookups — literal conf.instance[...] chains (multi-line,
.get("k")), non-literal subscripts as wildcards, sections bound to a local and
indexed later (closures included) and should_output("name") — and classes
every library settings key used / section-read / unused against the reads
of the whole stack (priors exempt; skipped if any library is missing).

Rendered as an unused chip on the key and per-file counts on the repo page,
a "Possibly unused config keys" index section grouped by library with GitHub
links, the class in board.json and the key index, and one info item per
library in state.json — never yellow. SOURCES gains each library's package
dir; the workflow's sparse checkout also fetches <package>/**/*.py.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SbKQQHRRgm2b69aT9t7771
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Sep 27, 2026
@Jammy2211
Jammy2211 merged commit eb27da2 into main Sep 27, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/nerves-unused-keys branch September 27, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(board): flag library config keys not in use anymore

1 participant