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

Code before:
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import final
    ///
    /// # Incorrect: type checkers will not prevent subclassing
    /// MyClass = final(type("MyClass", (), {}))
    ///
    /// # Correct: use `final` as a decorator
    /// @final
    /// class MyClass: ...
    /// ```
    pub(crate) static INEFFECTIVE_FINAL = {
        summary: "detects calls to `final()` that type checkers cannot interpret",
        status: LintStatus::stable("0.0.1-alpha.33"),
        default_level: Level::Warn,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for `@final` decorators applied to non-method functions.
    ///
    /// ## Why is this bad?
    /// The `@final` decorator is only meaningful on methods  and classes.
    /// Applying it to a module-level function or a nested function has no
    /// effect and is likely a mistake.
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import final
    ///
    /// # Error: @final is not allowed on non-method functions
    /// @final
    /// def my_function() -> int:
    ///     return 0
    /// ```
    pub(crate) static FINAL_ON_NON_METHOD = {
        summary: "detects `@final` applied to non-method functions",
        status: LintStatus::stable("0.0.20"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for `Final` symbols that are declared without a value and are never
    /// assigned a value in their scope.
    ///

Review comment (suggestion):
```suggestion
    /// The `@final` decorator is only meaningful on methods and classes.
```

Code after:
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import final
    ///
    /// # Incorrect: type checkers will not prevent subclassing
    /// MyClass = final(type("MyClass", (), {}))
    ///
    /// # Correct: use `final` as a decorator
    /// @final
    /// class MyClass: ...
    /// ```
    pub(crate) static INEFFECTIVE_FINAL = {
        summary: "detects calls to `final()` that type checkers cannot interpret",
        status: LintStatus::stable("0.0.1-alpha.33"),
        default_level: Level::Warn,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for `@final` decorators applied to non-method functions.
    ///
    /// ## Why is this bad?
    /// The `@final` decorator is only meaningful on methods and classes.
    /// Applying it to a module-level function or a nested function has no
    /// effect and is likely a mistake.
    ///
    /// ## Example
    ///
    /// ```python
    /// from typing import final
    ///
    /// # Error: @final is not allowed on non-method functions
    /// @final
    /// def my_function() -> int:
    ///     return 0
    /// ```
    pub(crate) static FINAL_ON_NON_METHOD = {
        summary: "detects `@final` applied to non-method functions",
        status: LintStatus::stable("0.0.20"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for `Final` symbols that are declared without a value and are never
    /// assigned a value in their scope.
    ///