Skip to content

RUF100 and E401 with auto-fix seem inconsistent #4655

@JannKleen

Description

@JannKleen

I have a Django app config that relies on importing some files on initialisation to get various functions in there registered. Having RUF100 enabled and running ruff with --fix, the following happens. The original looks like this:

        import api.checks  # noqa: F401
        import api.signals  # noqa: F401
        import app.celery  # noqa: F401
        import tools.something  # noqa: F401

Running ruff will 'fix' it to the following, which seems incorrect (api.checks isn't used in this file) but will work and stay like that across multiple ruff runs:

        import api.checks
        import api.signals  # noqa: F401
        import app.celery  # noqa: F401
        import tools.something  # noqa: F401

However if I modify it further to:

        import api.checks
        import api.signals
        import app.celery  # noqa: F401
        import tools.something  # noqa: F401

Both lines will get deleted the next time I run ruff and I end up with:

        import app.celery  # noqa: F401
        import tools.something  # noqa: F401

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