Skip to content

Errors for attempted autofixes visible to users even without passing --fix and for noqa lines #15229

@AA-Turner

Description

@AA-Turner

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

Metadata

Metadata

Assignees

Labels

cliRelated to the command-line interface

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions