Find Python files that import a module

MSAL

Marks Python source files that import the given module, matching the as-written import path rather than type attribution. Robust to type-checker canonicalization and to removed or unresolvable symbols, which makes it usable as a precondition for import-migration recipes where HasType would miss the file.

org.openrewrite.python.search.UsesImport

Required

The dotted module path to match against import statements, e.g. datetime or os.path. A file matches if it imports that module, a submodule of it, or a parent module of it. Matched against import syntax, not type attribution.

mod run . --recipe=org.openrewrite.python.search.UsesImport \ -P module=datetime

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.