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

Code before:
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for enum classes that are also generic.
    ///
    /// ## Why is this bad?
    /// Enum classes cannot be generic. Python does not support generic enums,
    /// and attempting to create one will result in a `TypeError` at runtime.
    ///
    /// ## Examples
    /// ```python
    /// from enum import Enum
    /// from typing import Generic, TypeVar
    ///
    /// T = TypeVar("T")
    ///
    /// # error: enum class cannot be generic
    /// class E[T](Enum):
    ///     A = 1
    ///
    /// # error: enum class cannot be generic
    /// class F(Enum, Generic[T]):
    ///     A = 1
    /// ```
    ///
    /// ## References
    /// - [Python documentation: Enum](https://docs.python.org/3/library/enum.html)
    pub(crate) static INVALID_GENERIC_ENUM = {
        summary: "detects generic enum classes",
        status: LintStatus::stable("0.0.10"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for the creation of invalid generic classes
    ///
    /// ## Why is this bad?
    /// There are several requirements that you must follow when defining a generic class.
    /// Many of these result in `TypeError` being raised at runtime if they are violated.
    ///
    /// ## Examples
    /// ```python
    /// from typing_extensions import Generic, TypeVar
    ///
    /// T = TypeVar("T")
    /// U = TypeVar("U", default=int)

Review comment (bug):
```suggestion
    /// # error: enum class cannot be generic (class creation fails with `TypeError`)
    /// class E[T](Enum):
    ///     A = 1
    ///
    /// # error: enum class cannot be generic (class creation fails with `TypeError`)
    /// class F(Enum, Generic[T]):
    ///     A = 1
    ///
    /// # error: enum class cannot be generic -- the class creation does not immediately fail...
    /// class G(Generic[T], Enum):
    ///     A = 1
    ///
    /// # ...but this raises `KeyError`:
    /// x: G[int]
```

Code after:
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for exception handlers that catch non-exception classes.
    ///
    /// ## Why is this bad?
    /// Catching classes that do not inherit from `BaseException` will raise a `TypeError` at runtime.
    ///
    /// ## Example
    /// ```python
    /// try:
    ///     1 / 0
    /// except 1:
    ///     ...
    /// ```
    ///
    /// Use instead:
    /// ```python
    /// try:
    ///     1 / 0
    /// except ZeroDivisionError:
    ///     ...
    /// ```
    ///
    /// ## References
    /// - [Python documentation: except clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
    /// - [Python documentation: Built-in Exceptions](https://docs.python.org/3/library/exceptions.html#built-in-exceptions)
    ///
    /// ## Ruff rule
    ///  This rule corresponds to Ruff's [`except-with-non-exception-classes` (`B030`)](https://docs.astral.sh/ruff/rules/except-with-non-exception-classes)
    pub(crate) static INVALID_EXCEPTION_CAUGHT = {
        summary: "detects exception handlers that catch classes that do not inherit from `BaseException`",
        status: LintStatus::stable("0.0.1-alpha.1"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for enum classes that are also generic.
    ///
    /// ## Why is this bad?
    /// Enum classes cannot be generic. Python does not support generic enums:
    /// attempting to create one will either result in an immediate `TypeError`
    /// at runtime, or will create a class that cannot be specialized in the way
    /// that a normal generic class can.
    ///
    /// ## Examples
    /// ```python