Skip to content

FURB143: Preserve identity for mutable fallbacks - #397

Open
dajiaohuang wants to merge 1 commit into
dosisod:masterfrom
dajiaohuang:repostew/20261021-furb143-identity
Open

dajiaohuang wants to merge 1 commit into
dosisod:masterfrom
dajiaohuang:repostew/20261021-furb143-identity

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 20, 2026 •

Copy link
Copy Markdown

Fixes #381

FURB143 currently suggests replacing empty mutable fallbacks such as items or [], table or {}, and tags or set() with the left operand. When that operand is empty, or returns the fallback object, while the replacement returns the original operand; the rewrite changes object identity and can change aliasing after mutation. This change only removes the mutable list/dict/set patterns; the existing immutable cases remain unchanged.

The existing FURB143 fixture now keeps the mutable cases as no-finding examples and retains the valid immutable cases.

Validation:

  • Production run_refurb on the base reproduced all three mutable suggestions; on this candidate it omits them while retaining the immutable-string suggestion. The changed golden fixture also matches the production runner (Python 3.13.13, Mypy 1.15.0).
  • Pinned development checks pass: Ruff, Black, isort, typos, and both Mypy targets (refurb and test --exclude 'test/data*').
  • pytest test/test_checks.py::test_checks was attempted on Windows but fails on the repository-wide golden path separator mismatch (Windows backslash paths vs POSIX slash paths in fixtures); isolating this test also falls below the suite's 100% coverage threshold. The changed fixture passes through production run_refurb with only path separators normalized. Full suite/e2e/docs and hosted CI results are unverified.

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.

[Bug]: FURB143 changes identity for empty mutable fallbacks

1 participant