Upgrade to Python 3.11
Recipe ID
org.openrewrite.python.migrate.UpgradeToPython311Artifactopenrewrite-migrate-pythonMigrate deprecated and removed APIs for Python 3.11 compatibility. This includes handling removed modules, deprecated functions, and API changes between Python 3.10 and 3.11.
Composite recipepythonmigration3.11Proprietary
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.python.migrate.UpgradeToPython311If the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-migrate-pythonDefinition
This recipe runs the following recipes in order.
- Upgrade to Python 3.10
org.openrewrite.python.migrate.UpgradeToPython310 - Replace
typing.Textwithstrorg.openrewrite.python.migrate.ReplaceTypingText - Change import
org.openrewrite.python.ChangeImport - Replace
configparser.SafeConfigParserwithConfigParserorg.openrewrite.python.migrate.ReplaceConfigparserSafeConfigParser - Replace
ConfigParser.readfp()withread_file()org.openrewrite.python.migrate.ReplaceConfigparserReadfp - Replace deprecated gettext l*gettext() functions
org.openrewrite.python.migrate.ReplaceGettextDeprecations - Change import
org.openrewrite.python.ChangeImport - Replace deprecated unittest method aliases
org.openrewrite.python.migrate.ReplaceUnittestDeprecatedAliases - Migrate
@asyncio.coroutinetoasync deforg.openrewrite.python.migrate.MigrateAsyncioCoroutine - Find deprecated
@asyncio.coroutinedecoratororg.openrewrite.python.migrate.FindAsyncioCoroutineDecorator - Find
socket.getfqdn()usageorg.openrewrite.python.migrate.FindSocketGetFQDN - Find deprecated
locale.getdefaultlocale()usageorg.openrewrite.python.migrate.FindLocaleGetdefaultlocale - Replace
re.template()withre.compile()and flagre.TEMPLATE/re.Torg.openrewrite.python.migrate.ReplaceReTemplate - org.openrewrite.python.migrate.UpgradePythonVersionTo311
org.openrewrite.python.migrate.UpgradePythonVersionTo311