Replace module __cached__ with __spec__.cached
ProprietaryThe import system no longer sets a module's __cached__ attribute in Python 3.15. Read __spec__.cached instead. Rewrites the bare name where the file does not assign it, through getattr since a module run as a script has no __spec__, and the attribute on a module an import binds or whose type resolves to a module.
org. openrewrite. python. migrate. ReplaceModuleCachedAttributemod run . --recipe= org. openrewrite. python. migrate. ReplaceModuleCachedAttributeInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.