mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 12:16:43 +00:00
## Summary Fixes https://github.com/astral-sh/ty/issues/1409 This PR allows `Final` instance attributes to be initialized in `__init__` methods, as mandated by the Python typing specification (PEP 591). Previously, ty incorrectly prevented this initialization, causing false positive errors. The fix checks if we're inside an `__init__` method before rejecting Final attribute assignments, allowing assignments during instance initialization while still preventing reassignment elsewhere. ## Test Plan - Added new test coverage in `final.md` for the reported issue with `Self` annotations - Updated existing tests that were incorrectly expecting errors - All 278 mdtest tests pass - Manually tested with real-world code examples --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
|---|---|---|
| .. | ||
| resources | ||
| src | ||
| tests | ||
| build.rs | ||
| Cargo.toml | ||
| mdtest.py | ||
| mdtest.py.lock | ||