Files
ruff/crates/ruff_python_parser/tests
SacrimentoandBrent Westbrook 888976c6ab [syntax-errors] Extend __debug__ write check to attribute targets (#27908)
## 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>
2026-11-03 13:06:40 -05:00
..