mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-24 01:39:22 +08:00
## Summary Ruff currently flags assigning to or deleting `__debug__` when it's a bare name (`__debug__ = False`, `del __debug__`), but not when it's an attribute target (`x.__debug__ = False`, `del x.__debug__`). CPython forbids both assigning to `x.__debug__` (`SyntaxError` on every supported Python version) and deleting `x.__debug__` only became a `SyntaxError` in Python 3.14. This PR extends the existing `__debug__` check to `Expr::Attribute` targets, gated on the target Python version for the deletion case. Part of #17412. ## Test Plan Added inline test_err/test_ok fixtures alongside the new `Expr::Attribute` check Cross-checked the version gating logic and errors against real CPython 3.12/3.13/3.14. --------- Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>