Skip to content

fix: CPY051 constructor calls, PPY019 comparison site, tombstone gaps - #70

Merged
BHUVANSH855 merged 4 commits into
mainfrom
pre-release
Nov 13, 2026
Merged

BHUVANSH855 merged 4 commits into
mainfrom
pre-release

Conversation

@BHUVANSH855

Copy link
Copy Markdown
Owner

Summary

Three precision fixes identified by independent senior-developer review before showing PyRift to CPython/PyPy contributors:

  • CPY051 — constructor call coverage: _collect_module_mutable previously only detected mutable state created with literal syntax ([], {}, set()). Module-level list(), dict(), set(), bytearray(), collections.deque(), collections.defaultdict(), etc. were silently missed. The fix adds _is_mutable_constructor() and extends the value-check to cover both literals and constructor calls. +5 tests.

  • PPY019 — finding at the right node: The rule previously fired at the float('nan') creation site, causing false positives on any helper that creates a NaN object for downstream use. The fix rewrites the rule to walk ast.Compare nodes and fire only when a float('nan') call appears as an operand of is / is not. Bare assignments are now a documented true negative. Test suite fully rewritten (+12 tests including true-negative cases).

  • CLI explain — intentional gap messaging: pyrift explain CPY058 (and CPY059–CPY061) previously returned the generic unknown rule ID error, indistinguishable from a typo. These slots were intentionally never assigned. The fix adds gap-range detection in _run_explain and returns a clear "intentional gap in the rule numbering" message with a pointer to CPY062. +5 tests.

Test plan

  • pytest — 1811 passed, 0 failed
  • ruff check . — no issues
  • mypy pyrift/ — no issues
  • pyrift explain CPY058 returns "intentional gap" message
  • pyrift explain CPY052 still returns "retired rule" message
  • _cache = list() + mutation now triggers CPY051
  • x = float('nan') (bare assignment) no longer triggers PPY019
  • x is float('nan') triggers PPY019

@BHUVANSH855
BHUVANSH855 merged commit 9649881 into main Nov 13, 2026
24 checks passed
@BHUVANSH855
BHUVANSH855 deleted the pre-release branch November 13, 2026 08:16
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