test(adcp): docstring/env-var consistency test#440
Merged
Conversation
Adds tests/test_docstring_consistency.py, which AST-parses public method docstrings across src/adcp/, extracts env-var names documented as active (via ``VARNAME=value`` assignment syntax or env-var context keywords), and asserts each one is backed by a real os.environ read in the source tree. Closes #424 https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
Address pre-PR review blockers: - Replace single greedy regex with two-step approach (backtick span extraction + word-boundary SCREAMING_CASE search) to avoid matching suffixes like P_ENV from ADCP_ENV. - Add ±1 line sliding window for Pattern B context keywords so ADCP_ENV on one line / "flips" on the next is correctly detected. - Remove standalone "overrides" from context keywords to prevent false positives from OOP-override prose. - Drop bare `ignored?` from exclusion pattern; keep only "deliberately" and "not honored" to avoid suppressing legitimate active-var checks. - Fix module-level lineno fallback to 1 (not 0). - Add known-limitations section to module docstring. https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #424
Adds
tests/test_docstring_consistency.py. The test AST-parses all public method, class, and module docstrings insrc/adcp/, extracts env-var names documented as active, and asserts each one is backed by a realos.environread in the source tree. CI fails on drift — the original trigger wasclient.py:381-388claimingPYTHON_ENV/ENV/ENVIRONMENTwere honored when onlyADCP_ENVwas.Detection logic:
VARNAME=valueinside RST double-backtick literals (e.g.ADCP_VALIDATION_MODE=strict|warn|off). Direct signal that a var is documented as settable.environ,env var,environment variable,flips) in the ±1-line window. The sliding window catchesADCP_ENVon one line whenflips …appears on the next. Restricted to backtick-wrapped tokens;overridesexcluded as standalone keyword to prevent OOP-override false positives.deliberatelyornot honoredare skipped.What was tested:
pytest tests/test_docstring_consistency.py— 1 passedmypy tests/test_docstring_consistency.py— no issuesruff check tests/test_docstring_consistency.py— all checks passedPre-PR review:
overrideskeyword, bareignored?exclusion) all resolved in the second commitKnown limitations (documented in module docstring):
PORT) are invisible to both patterns_env_vars_in_use()scans raw text; a docstring example embedding a fictionalos.environ["FAKE_VAR"]would suppress that name in the in-use setast.walkcollects public methods inside private classes (over-approximation)Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
Generated by Claude Code