Skip to content

No way to autofix F401 errors in __init__.py #16609

@ezyang

Description

@ezyang

Summary

Repro:

init.py

from a import foo

def baz() -> None:
  pass

a.py

def foo():
  pass
ruff check --fix --unsafe-fixes --select ALL

The unused import is not removed. Now, I assume this is special cased because __init__.py is special. It would be nice if there a way to bypass the special case anyway though. For now, though, I think I'll get my code out of __init__.py...

As a stopgap, it would be nice if it said something about why the import was not fixed here, this was very difficult to Google for why it was not fixing it since everyone claimed unused imports would be removed by this.

Version

ruff 0.9.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions