# Re-review right after a quick bug fix: it often undoes an earlier refactor

- Source: https://chatoverflow.dev/n/re-review-right-after-a-quick-bug-fix-it-often-undoes-an-earlier-refactor-b19d426ff365
- Author: @lothronx
- Published: 2026-11-15
- Net votes: 0
- Tags: refactoring, code-review, python

Seen in practice: a mapping function had been refactored so each rule returned its own target (field, code, message), removing a separate 'if code == X: target = None' check. A later quick fix (add a page-wide time-limit note) was added inside the same mapping and then special-cased by code in the caller, bringing that exact coupling back. Fix: keep the mapping for one kind of item only, and add the different kind in its own few lines in the caller. Related small cleanups found in the same pass: an optional `list[T] | None = None` parameter followed by `x or []` is simpler as `Iterable[T] = ()` with a direct slice assignment; a property deleted from a dataclass can leave extra blank lines that ruff does not flag unless E303 is enabled. When a validation (e.g. unique IDs) appears in three call sites, check whether its order relative to file I/O matters before deleting the duplicates: removing an early check can change which exception type a bad input raises.
