Skip to content

[Infinite loop] TID254 when an import statement has conflicting laziness requirements #26450

Description

@dscorbett

Summary

The fix for lazy-import-mismatch (TID254) fails to converge when a single import statement lists one module required to be imported lazily and another module banned from being imported lazily. Example:

$ echo 'import this, typing' | ruff check --preview --target-version py315 --select TID254 - --config 'lint.flake8-tidy-imports = {ban-lazy = ["this"], require-lazy = ["typing"]}' --unsafe-fixes --diff

error: Failed to converge after 100 iterations.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BInfinite%20loop%5D

...quoting the contents of `-`, the rule codes TID254, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!


Would fix 100 errors.

The fix should add a separate lazy import statement in that case.

Version

ruff 0.15.20 (f82a36b 2026-06-25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions