Repository: astral-sh/ruff
File: crates/ty_python_semantic/src/types/diagnostic.rs (Rust)

Code before:
    ///
    /// class B(A):
    ///     def foo(self): ...  # Error raised here
    /// ```
    pub(crate) static OVERRIDE_OF_FINAL_METHOD = {
        summary: "detects overrides of final methods",
        status: LintStatus::stable("0.0.1-alpha.29"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for calls to `final()` where the decorator has no effect.
    ///
    /// ## Why is this bad?
    /// The `final()` function is designed to be used as a decorator. When called directly
    /// as a function (e.g., `final(type(...))`), it simply returns its argument unchanged
    /// and has no effect at runtime or for type checking.
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import final
    ///
    /// # Incorrect: `final()` has no effect when called as a function
    /// MyClass = final(type("MyClass", (), {}))
    ///
    /// # Correct: use `final` as a decorator
    /// @final
    /// class MyClass: ...
    /// ```
    pub(crate) static INEFFECTIVE_FINAL = {
        summary: "detects calls to `final()` that have no effect",
        status: LintStatus::preview("0.0.1-alpha.33"),
        default_level: Level::Warn,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for methods that are decorated with `@override` but do not override any method in a superclass.
    ///
    /// ## Why is this bad?
    /// Decorating a method with `@override` declares to the type checker that the intention is that it should
    /// override a method from a superclass.
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import override

Review comment (suggestion):
Some of this is technically not true. `typing.final` does have a runtime effect: it sets `__final__ = True` on the class. So I think we need to re-word this a bit more conservatively, to just say "type checkers won't understand this application of `final` or prevent subclassing."

Code after:
        default_level: Level::Ignore,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for classes that subclass final classes.
    ///
    /// ## Why is this bad?
    /// Decorating a class with `@final` declares to the type checker that it should not be subclassed.
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import final
    ///
    /// @final
    /// class A: ...
    /// class B(A): ...  # Error raised here
    /// ```
    pub(crate) static SUBCLASS_OF_FINAL_CLASS = {
        summary: "detects subclasses of final classes",
        status: LintStatus::stable("0.0.1-alpha.1"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for methods on subclasses that override superclass methods decorated with `@final`.
    ///
    /// ## Why is this bad?
    /// Decorating a method with `@final` declares to the type checker that it should not be
    /// overridden on any subclass.
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import final
    ///
    /// class A:
    ///     @final
    ///     def foo(self): ...
    ///
    /// class B(A):
    ///     def foo(self): ...  # Error raised here
    /// ```
    pub(crate) static OVERRIDE_OF_FINAL_METHOD = {
        summary: "detects overrides of final methods",
        status: LintStatus::stable("0.0.1-alpha.29"),
        default_level: Level::Error,