ruff/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_17.py
2023-09-20 08:38:27 +02:00

32 lines
769 B
Python

"""Test that runtime typing references are properly attributed to scoped imports."""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
if TYPE_CHECKING:
from threading import Thread
def fn(thread: Thread):
from threading import Thread
# The `Thread` on the left-hand side should resolve to the `Thread` imported at the
# top level.
x: Thread
def fn(thread: Thread):
from threading import Thread
# The `Thread` on the left-hand side should resolve to the `Thread` imported at the
# top level.
cast("Thread", thread)
def fn(thread: Thread):
from threading import Thread
# The `Thread` on the right-hand side should resolve to the`Thread` imported within
# `fn`.
cast(Thread, thread)