Skip to content

TC001 - TC003 should not apply with lazy imports #25181

@stephenfin

Description

@stephenfin

Summary

PEP 810 (Explicit lazy imports) specifically calls out lazy imports as eliminat[ing] the common need for TYPE_CHECKING guards. While TYPE_CHECKING may still have a use for avoiding circular imports, it's does cause a lot of issues for tools that rely on runtime behavior (think: sphinx.ext.autodoc, beartype, etc.). Would it make sense to deprecate these rules or discourage their use code bases that only support Python 3.15 or greater, on the basis that users would be better off using lazy imports to avoid these expensive imports?

Metadata

Metadata

Assignees

No one assigned

    Labels

    python315ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions