Skip to content

Check that public functions and classes have outside callers - #229

Merged
fniessink merged 1 commit into
mainfrom
check-public-private
Aug 11, 2026
Merged

Check that public functions and classes have outside callers#229
fniessink merged 1 commit into
mainfrom
check-public-private

Conversation

@fniessink

Copy link
Copy Markdown
Member

The architecture test checked module-level constants only, so a function or class whose last caller outside its module went away kept claiming callers it no longer had. It now covers functions and classes too, bar the names nothing calls: a class a framework discovers by scanning, and the function behind a module's if __name__ == "__main__" guard. The 48 names it reported across src, tests, and tools are private now.

CacheClearingTestCase also stopped listing the caches it clears; it walks the package and clears every @cache it finds. The visibility check moved to test_visibility.py, since it reads what modules expose rather than how they depend on one another.

The architecture test checked module-level constants only, so a function or class whose last caller outside its module went away kept claiming callers it no longer had. It now covers functions and classes too, bar the names nothing calls: a class a framework discovers by scanning, and the function behind a module's `if __name__ == "__main__"` guard. The 48 names it reported across `src`, `tests`, and `tools` are private now.

`CacheClearingTestCase` also stopped listing the caches it clears; it walks the package and clears every `@cache` it finds. The visibility check moved to `test_visibility.py`, since it reads what modules expose rather than how they depend on one another.

`just rename` renames a module-level name and every reference to it, through LibCST's `RenameCommand`, which resolves the name against each module's scopes: the same word in a docstring, a help string, or an f-string is left alone, and so is a parameter or a local of that name. LibCST counts the files it read rather than the ones it rewrote and exits 0 whether it found the name or not, so the recipe compares the files and fails when nothing changed. CLAUDE.md now sends a rename there rather than to a substitution.
@fniessink
fniessink force-pushed the check-public-private branch from 847d54f to c3dd4f6 Compare August 11, 2026 15:25
@fniessink
fniessink merged commit d463656 into main Aug 11, 2026
1 check passed
@fniessink
fniessink deleted the check-public-private branch August 11, 2026 15:29
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