Skip to content

F401 false positive with PEP-695 upper bound specification #8017

@bryanforbes

Description

@bryanforbes

Running the following command with Ruff 0.1.0:

ruff --target-version py312 --select F401 --isolated --no-cache blah.py

Given the following code:

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from collections.abc import Callable

    from .foo import Record

type RecordCallback[R: Record] = Callable[[R], None]


def process_record[R: Record](record: R) -> None:
    ...


class RecordContainer[R: Record]:
    def add_record(self, record: R) -> None:
        ...

F401 is reported on line 8, but Record is being used in the upper bound specifications.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions