Definition
Recipes18
18 recipes
- Upgrade to Python 3.11
- Replace
datetime.utcnow()withdatetime.now(UTC) - Replace
datetime.utcfromtimestamp()withdatetime.fromtimestamp(ts, UTC) - Replace deprecated calendar constants with uppercase
- Change import
- Find deprecated imp module usage
- Replace deprecated distutils.version usage
- Find deprecated distutils module usage
- Replace
pkgutil.find_loader()withimportlib.util.find_spec() - Replace
pkgutil.get_loader()withimportlib.util.find_spec() - Find deprecated
Path.link_to()usage - Find modules removed in Python 3.12
- Find deprecated
ssl.match_hostname() - Find deprecated
os.popen()usage - Find deprecated
os.spawn*()usage - Find deprecated
shutil.rmtree(onerror=...)parameter - Replace
sys.last_type/sys.last_value/sys.last_tracebackwithsys.last_exc - org.openrewrite.python.migrate.UpgradePythonVersionTo312
Usage
Run this recipe
In order to run Python recipes, you will need to use the Moderne CLI.
Once the CLI is installed, you can install this Python recipe package by running the following command:
Install the recipe package
mod config recipes pip install openrewrite-migrate-python==0.9.3
Then, you can run the recipe via:
Run the recipe
mod run . --recipe org.openrewrite.python.migrate.UpgradeToPython312