Skip to content

Identical import inside+outside of TYPE_CHECKING block does not emit F811 #17555

@injust

Description

@injust

Summary

from __future__ import annotations

from collections.abc import AsyncGenerator, Iterable
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from collections.abc import AsyncGenerator, Iterable

async def foo(bar: Iterable[int]) -> AsyncGenerator[int]:
    pass

https://play.ruff.rs/5b99b487-12b4-45f7-b212-b8e5bdfc63bd

The from collections.abc import is repeated inside and outside the if TYPE_CHECKING block. I expected this to trigger some combination of TC003 and/or F811, but Ruff doesn't report any errors.

Version

0.11.6

Metadata

Metadata

Assignees

No one assigned

    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