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

Code before:
declare_lint! {
    /// ## What it does
    /// Checks for attempts to override prohibited attributes in `NamedTuple` classes.
    ///
    /// ## Why is this bad?
    /// `NamedTuple` classes have certain synthesized attributes (like `_asdict`, `_make`,
    /// `_replace`, etc.) that cannot be overwritten. Attempting to assign to these attributes
    /// without a type annotation will raise an `AttributeError` at runtime.
    ///
    /// ## Examples
    /// ```python
    /// from typing import NamedTuple
    ///
    /// class F(NamedTuple):
    ///     x: int
    ///     _asdict = 42  # error: Cannot overwrite NamedTuple attribute _asdict
    /// ```
    ///
    /// ## References
    /// - [Python documentation: NamedTuple](https://docs.python.org/3/library/typing.html#typing.NamedTuple)
    pub(crate) static OVERRIDE_OF_PROHIBITED_NAMED_TUPLE_ATTRIBUTE = {
        summary: "detects attempts to override prohibited `NamedTuple` attributes",
        status: LintStatus::preview("0.0.1-alpha.30"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for calls to `reveal_type` without importing it.
    ///
    /// ## Why is this bad?
    /// Using `reveal_type` without importing it will raise a `NameError` at runtime.
    ///
    /// ## Examples
    /// ```python
    /// reveal_type(1)  # NameError: name 'reveal_type' is not defined
    /// ```
    pub static UNDEFINED_REVEAL = {
        summary: "detects usages of `reveal_type` without importing it",
        status: LintStatus::stable("0.0.1-alpha.1"),
        default_level: Level::Warn,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for keyword arguments in calls that don't match any parameter of the callable.
    ///
    /// ## Why is this bad?
    /// Providing an unknown keyword argument will raise `TypeError` at runtime.

Review comment (bug):
is it worth adding a new error code just for this, or would it be better to reuse the `invalid-named-tuple` error code? The name of the new error code seems _very_ long... and I'm not sure I can think of a situation where a user would want to e.g. enable one error code spotting ways namedtuple class creation might fail, but disable another error code that also spots ways namedtuple class creation might fail.

The examples are nice though; we could add those for sure!

Code after:
    ///
    /// ## Examples
    /// ```python
    /// from typing import NamedTuple
    ///
    /// class F(NamedTuple):
    ///     x: int
    ///
    ///     def method(self):
    ///         super()  # error: super() is not supported in methods of NamedTuple classes
    /// ```
    ///
    /// ## References
    /// - [Python documentation: super()](https://docs.python.org/3/library/functions.html#super)
    pub(crate) static SUPER_CALL_IN_NAMED_TUPLE_METHOD = {
        summary: "detects `super()` calls in methods of `NamedTuple` classes",
        status: LintStatus::preview("0.0.1-alpha.30"),
        default_level: Level::Error,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for calls to `reveal_type` without importing it.
    ///
    /// ## Why is this bad?
    /// Using `reveal_type` without importing it will raise a `NameError` at runtime.
    ///
    /// ## Examples
    /// ```python
    /// reveal_type(1)  # NameError: name 'reveal_type' is not defined
    /// ```
    pub static UNDEFINED_REVEAL = {
        summary: "detects usages of `reveal_type` without importing it",
        status: LintStatus::stable("0.0.1-alpha.1"),
        default_level: Level::Warn,
    }
}

declare_lint! {
    /// ## What it does
    /// Checks for keyword arguments in calls that don't match any parameter of the callable.
    ///
    /// ## Why is this bad?
    /// Providing an unknown keyword argument will raise `TypeError` at runtime.
    ///
    /// ## Example
    ///
    /// ```python
    /// def f(x: int) -> int: ...
    ///