Skip to content

cleanup - #5

Merged
Sau1707 merged 1 commit into
mainfrom
automation/opencode-cleanup
Nov 2, 2026
Merged

Sau1707 merged 1 commit into
mainfrom
automation/opencode-cleanup

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

refactor: Simplify analyzer state and rule traversal

Summary

Implemented all five reviewed simplification candidates across nine files:

  • Index constant references once per scope instead of rescanning the AST for each candidate; deduplicate repeated declaration names.
  • Collect control-flow weights in one shared accumulator rather than recursively constructing and merging dictionaries.
  • Inspect adjacent iterable consumers directly while retaining single-use, closure, builtin-identity, and snapshot safeguards.
  • Centralize binding and contract restoration in a private scope context manager, keeping function-stack ownership at the call site.
  • Replace coupled endpoint return-summary flags with a per-endpoint set of return kinds.
  • Add regression coverage for scope restoration after exceptions, independent constant ordering, repeated declarations, nested control weights, and adjacent consumer argument/statement forms.

The changes are intended to preserve existing diagnostic behavior and public CLI behavior.

Validation

Passed

  • Baseline test suite before editing: 393 passed.
  • Final full suite on Python 3.14: 407 passed.
  • Full suite on the minimum supported Python 3.10: 406 passed, 1 skipped. The existing exception-group test requires Python 3.11 or newer.
  • uvx pyunslop: Checks passed after resolving warnings introduced during implementation.
  • uv run pyunslop: Checks passed, exercising the local implementation.
  • Ruff lint across all nine changed files: passed.
  • Targeted Ruff formatting recheck across six changed files: passed.
  • Final git diff --check: passed.

Failed checks and resolution

  • An intermediate test run had three failures because the new exception-restoration test patched an absent visitor method without enabling dynamic attribute creation. The test setup was corrected; the final suites pass.
  • An intermediate pyunslop run reported five complexity-budget warnings in changed code. These were resolved; both final checker runs pass.
  • Repository-wide Ruff lint reported six issues. The two introduced in the changed binding visitor were fixed. Four pre-existing issues remain in untouched files: builtin-name shadowing in src/pyunslop/__init__.py and src/pyunslop/diagnostics.py, and import ordering in src/pyunslop/analysis/__init__.py and src/pyunslop/rules/simplifications.py.
  • The initial changed-file Ruff formatting check reported four files. Formatting of the newly added test was corrected. Pre-existing blank-line/comment formatting differences remain in src/pyunslop/analysis/bindings.py, src/pyunslop/rules/comments.py, and src/pyunslop/rules/materialization.py. The full nine-file formatting check was not rerun; the subsequent six-file targeted check passed.

Remaining limitations

  • Existing Ruff lint and formatting issues were intentionally left outside this cleanup's scope. Ruff also reports existing conflicting docstring-rule configuration warnings.
  • Verification covers the full existing suite and added regressions, but does not constitute an exhaustive proof of diagnostic equivalence or a performance benchmark.
  • uv was initially unavailable and was installed in an isolated temporary tooling environment to complete verification.

Labels

  • Change type: refactor. The exact release label could not be confirmed because .github/release.yml is absent.
  • Area: Python analyzer/library; none of the prescribed api, sdk, or web area labels clearly applies.

@Sau1707
Sau1707 merged commit 23f5a7c into main Nov 2, 2026
1 check passed
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