Skip to content

PYI034 false positive if Self is a quoted annotation #12928

@BenGale93

Description

@BenGale93

List of keywords searched:

  • PYI034

Code example:

import typing as t

if t.TYPE_CHECKING:
    from typing_extensions import Self


class Foo:
    def __init__(self, x: int) -> None:
        self.x = x

    def __iadd__(self, other: "Self") -> "Self":
        """Adds two Foo objects together."""
        self.x += other.x
        return self

Command: ruff check file.py --isolated --select=PYI034

Ruff Version: 0.5.7

I'd be happy to try and fix this as I have some Rust experience. Please let me know if I can be of help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedReady for implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions