You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Relatedly - replacing existing if TYPE_CHECKING: ... imports with lazy imports.
Suggesting lazy imports any time we see an import not at the beginning of the file. (Developers sometimes approximate lazy imports these days by importing in the body of a function, for example.)
This issue tracks support for
lazyimports in Ruff.Python 3.15 introduced PEP 810 - Explicit lazy imports. We have done the following:
But we may also want to consider some lints. For example:
lazykeyword when sorting imports #23762flake8-type-checkingto suggest that typing-only imports be lazily imported rather than gated behindif TYPE_CHECKING, as per this use-case in the PEP.if TYPE_CHECKING: ...imports with lazy imports.lazyif we can guarantee that the import will be evaluated (e.g. by a top-level statement in the module).