[ty] Detect invalid uses of @final on non-methods by AlexWaygood · Pull Request #23604 · astral-sh/ruff (original) (raw)

and others added 5 commits

February 27, 2026 11:44

@claude

…functions

Per the typing spec, @final is only valid on methods and classes. Using it on a module-level function or a nested function is an error. This adds a new final-on-non-method lint rule that detects this misuse and emits a diagnostic.

This should cause the upstream conformance test qualifiers_final_decorator.py to pass, as the only previously missing check was for @final applied to non-method functions.

https://claude.ai/code/session_015ajybUNEuqCYeVVnSsiFCS

@claude

@claude

@claude

@AlexWaygood

@AlexWaygood @sharkdp

Co-authored-by: David Peter sharkdp@users.noreply.github.com

@AlexWaygood AlexWaygood deleted the claude/typing-final-diagnostic-VlF5R branch

February 27, 2026 13:30

carljm added a commit that referenced this pull request

Feb 27, 2026

@carljm

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})