I think related to #5454. cc @MichaReiser @wookie184
Reproducer:
Save to bug.py:
# bug.py
from typing import Callable
def spam() -> None:
C = Callable[[int], None] # NoQA: UP006
_ = C
_ = Callable # NoQA: UP006
Run the following:
PS> ruff --version
ruff 0.8.5
PS> ruff clean; ruff check bug.py --isolated --select UP006 --preview
Removing cache at: .ruff_cache
error: Failed to create fix for NonPEP585Annotation: Unable to insert `Callable` into scope due to name conflict
error: Failed to create fix for NonPEP585Annotation: Unable to insert `Callable` into scope due to name conflict
All checks passed!
Note the error only appears when there is no existing cache, hence ruff clean. Adding or removing from __future__ import annotations has no effect.
A