openrewrite-migrate-python 0.14.0.dev20260903174925__tar.gz → 0.14.0.dev20260904170449__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/PKG-INFO +2 -2
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/pyproject.toml +2 -6
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/_reindent.py +0 -16
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/all_branches_identical.py +2 -3
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/collapsible_if_statements.py +2 -4
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/_from_imports.py +17 -6
- openrewrite_migrate_python-0.14.0.dev20260904170449/src/openrewrite_migrate_python/migrate/_typing_imports.py +71 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/gettext_deprecations.py +2 -2
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/locale_deprecations.py +3 -1
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/platform_deprecations.py +1 -1
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/ssl_deprecations.py +1 -1
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/typing_deprecations.py +1 -52
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python.egg-info/PKG-INFO +2 -2
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python.egg-info/requires.txt +1 -1
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_gettext_deprecations.py +16 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_locale_deprecations.py +44 -0
- openrewrite_migrate_python-0.14.0.dev20260903174925/src/openrewrite_migrate_python/migrate/_typing_imports.py +0 -164
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/setup.cfg +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/__init__.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/__init__.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/_semantically_equal.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/_trivia.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/boolean_checks_not_inverted.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/find_suspicious_chained_comparison.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/merge_identical_branches.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/remove_duplicate_conditions.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/remove_self_assignment.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/remove_unconditional_value_overwrite.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/simplify_boolean_literal.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_code_quality_python/codequality/simplify_redundant_logical_expression.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/__init__.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/__init__.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/_import_hygiene.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/_langchain_tables.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/_markers.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/_slots.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/aifc_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/array_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/ast_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/asyncio_coroutine_to_async.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/asyncio_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/avro_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/calendar_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/cgi_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/cgi_parse_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/collections_abc_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/configparser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/datetime_utc.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/distutils_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/distutils_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/functools_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/future_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/html_parser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/imp_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/langchain_classic_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/langchain_community_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/langchain_provider_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/locale_getdefaultlocale_deprecation.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/macpath_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/mailcap_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/nntplib_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/os_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/pathlib_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/pep594_system_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/pipes_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/pkgutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/pydantic_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/pydantic_fields.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/pydantic_model_fields.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/re_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/removed_modules_312.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/shutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/socket_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/string_formatting.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/sys_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/sys_last_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/tarfile_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/telnetlib_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/tempfile_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/threading_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/threading_is_alive_deprecation.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/typing_callable.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/typing_union_to_pipe.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/unittest_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_langchain02.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_langchain1.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_pydantic.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_python310.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_python311.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_python312.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_python313.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_python314.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_python38.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/upgrade_to_python39.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/urllib_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/uu_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/xdrlib_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python/migrate/xml_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python.egg-info/SOURCES.txt +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python.egg-info/dependency_links.txt +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python.egg-info/entry_points.txt +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/src/openrewrite_migrate_python.egg-info/top_level.txt +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_aifc_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_array_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_ast_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_asyncio_coroutine_to_async.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_asyncio_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_avro_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_calendar_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_cgi_parse_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_change_import_recipes.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_collections_abc_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_configparser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_datetime_utc.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_distutils_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_future_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_html_parser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_imp_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_langchain_classic_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_langchain_community_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_langchain_provider_imports.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_locale_getdefaultlocale_deprecation.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_macpath_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_os_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_pep594_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_pep594_system_migrations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_pkgutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_platform_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_pydantic_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_pydantic_fields.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_pydantic_model_fields.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_re_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_removed_modules_312.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_shutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_ssl_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_string_formatting.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_sys_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_sys_last_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_tarfile_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_threading_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_threading_extended.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_threading_is_alive_deprecation.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_typing_alias_moves.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_typing_callable.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_typing_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_typing_union_to_pipe.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_unittest_deprecations.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_upgrade_recipes.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_upgrade_to_pydantic.py +0 -0
- {openrewrite_migrate_python-0.14.0.dev20260903174925 → openrewrite_migrate_python-0.14.0.dev20260904170449}/tests/test_xml_deprecations.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openrewrite-migrate-python
|
|
3
|
-
Version: 0.14.0.
|
|
3
|
+
Version: 0.14.0.dev20260904170449
|
|
4
4
|
Summary: OpenRewrite recipes for migrating Python codebases to newer Python versions.
|
|
5
5
|
Author-email: "Moderne Inc." <support@moderne.io>
|
|
6
6
|
License: Moderne Proprietary
|
|
@@ -21,7 +21,7 @@ Classifier: Typing :: Typed
|
|
|
21
21
|
Requires-Python: >=3.10
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
Provides-Extra: dev
|
|
24
|
-
Requires-Dist: openrewrite>=8.91.
|
|
24
|
+
Requires-Dist: openrewrite>=8.91.5; extra == "dev"
|
|
25
25
|
Requires-Dist: pydantic>=2.11; extra == "dev"
|
|
26
26
|
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
27
27
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "openrewrite-migrate-python"
|
|
7
7
|
description = "OpenRewrite recipes for migrating Python codebases to newer Python versions."
|
|
8
|
-
version = "0.14.0.
|
|
8
|
+
version = "0.14.0.dev20260904170449" # Updated dynamically during release
|
|
9
9
|
authors = [{ name = "Moderne Inc.", email = "support@moderne.io" }]
|
|
10
10
|
license = { text = "Moderne Proprietary" }
|
|
11
11
|
readme = "README.md"
|
|
@@ -30,11 +30,7 @@ dependencies = []
|
|
|
30
30
|
|
|
31
31
|
[project.optional-dependencies]
|
|
32
32
|
dev = [
|
|
33
|
-
|
|
34
|
-
# against: the current release, so that recipes meet the LST a current CLI produces.
|
|
35
|
-
# 8.91.4 is the first with `Py.Shebang` (openrewrite/rewrite#8729), which a shebanged
|
|
36
|
-
# file puts at `statements[0]` ahead of its imports.
|
|
37
|
-
"openrewrite>=8.91.4",
|
|
33
|
+
"openrewrite>=8.91.5",
|
|
38
34
|
# Needed so type-attribution tests can resolve `pydantic` types.
|
|
39
35
|
"pydantic>=2.11",
|
|
40
36
|
"pytest>=8.0.0",
|
|
@@ -7,8 +7,6 @@ to a shallower nesting level means rewriting every line it spans.
|
|
|
7
7
|
from typing import Optional, TypeVar
|
|
8
8
|
|
|
9
9
|
from rewrite.java.support_types import Space
|
|
10
|
-
from rewrite.java.tree import Statement
|
|
11
|
-
from rewrite.python.tree import ExpressionStatement, StatementExpression
|
|
12
10
|
from rewrite.python.visitor import PythonVisitor
|
|
13
11
|
|
|
14
12
|
T = TypeVar("T")
|
|
@@ -27,20 +25,6 @@ def inherited_prefix(dropped: Space, body: Space) -> Space:
|
|
|
27
25
|
)
|
|
28
26
|
|
|
29
27
|
|
|
30
|
-
def with_prefix(stmt: Statement, prefix: Space) -> Statement:
|
|
31
|
-
"""Set the prefix of *stmt*, threading through the ``Py`` wrappers whose
|
|
32
|
-
own prefix is a read-only view of the node they hold.
|
|
33
|
-
|
|
34
|
-
Drop once openrewrite/rewrite#8742 is the version floor: it gives those
|
|
35
|
-
wrappers a write path, so `stmt.replace(_prefix=...)` suffices alone.
|
|
36
|
-
"""
|
|
37
|
-
if isinstance(stmt, ExpressionStatement):
|
|
38
|
-
return stmt.replace(_expression=with_prefix(stmt.expression, prefix))
|
|
39
|
-
if isinstance(stmt, StatementExpression):
|
|
40
|
-
return stmt.replace(_statement=with_prefix(stmt.statement, prefix))
|
|
41
|
-
return stmt.replace(_prefix=prefix)
|
|
42
|
-
|
|
43
|
-
|
|
44
28
|
def line_indent(space: Space) -> Optional[str]:
|
|
45
29
|
"""Indentation of the line the token following *space* starts on, or
|
|
46
30
|
``None`` when that token shares a line with what precedes it.
|
|
@@ -25,7 +25,6 @@ from openrewrite_code_quality_python.codequality._reindent import (
|
|
|
25
25
|
inherited_prefix,
|
|
26
26
|
line_indent,
|
|
27
27
|
reindent,
|
|
28
|
-
with_prefix,
|
|
29
28
|
)
|
|
30
29
|
from openrewrite_code_quality_python.codequality._semantically_equal import SemanticallyEqual
|
|
31
30
|
|
|
@@ -193,8 +192,8 @@ def _replace_identical_ifs_padded(padded_stmts) -> Optional[list]:
|
|
|
193
192
|
# separating it from the next one is recorded.
|
|
194
193
|
result.append(
|
|
195
194
|
first.replace(
|
|
196
|
-
_element=
|
|
197
|
-
|
|
195
|
+
_element=first.element.replace(
|
|
196
|
+
_prefix=inherited_prefix(s.prefix, first.element.prefix)
|
|
198
197
|
)
|
|
199
198
|
)
|
|
200
199
|
)
|
|
@@ -36,7 +36,6 @@ from openrewrite_code_quality_python.codequality._reindent import (
|
|
|
36
36
|
inherited_prefix,
|
|
37
37
|
line_indent,
|
|
38
38
|
reindent,
|
|
39
|
-
with_prefix,
|
|
40
39
|
)
|
|
41
40
|
|
|
42
41
|
_CodeQuality = [
|
|
@@ -198,9 +197,8 @@ class CollapsibleIfStatements(Recipe):
|
|
|
198
197
|
inner_body = inner_body.replace(
|
|
199
198
|
_statements=[
|
|
200
199
|
first.replace(
|
|
201
|
-
_element=
|
|
202
|
-
first.element
|
|
203
|
-
inherited_prefix(inner.prefix, first.element.prefix),
|
|
200
|
+
_element=first.element.replace(
|
|
201
|
+
_prefix=inherited_prefix(inner.prefix, first.element.prefix)
|
|
204
202
|
)
|
|
205
203
|
),
|
|
206
204
|
*inner_body._statements[1:],
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"""Resolving a receiver-less call to the module member it was imported from."""
|
|
2
2
|
|
|
3
|
-
from typing import Dict, Optional
|
|
3
|
+
from typing import Dict, Optional, Set
|
|
4
4
|
|
|
5
5
|
from rewrite import Cursor
|
|
6
6
|
from rewrite.java.tree import FieldAccess, Identifier, J, MethodInvocation
|
|
7
|
+
from rewrite.python import scope_of
|
|
7
8
|
from rewrite.python.import_utils import get_alias_name, get_name_string, get_qualid_name
|
|
8
9
|
from rewrite.python.scope_utils import LocalBindings
|
|
9
10
|
from rewrite.python.tree import CompilationUnit, MultiImport
|
|
@@ -19,18 +20,17 @@ def _is_relative(from_: J) -> bool:
|
|
|
19
20
|
class FromImports:
|
|
20
21
|
"""The members of ``module`` a file binds with ``from <module> import <member>``.
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
these APIs span many versions, so no declared version resolves them all —
|
|
25
|
-
attribution quality does not make this fallback redundant.
|
|
23
|
+
A call spells the name its import bound, which an alias makes differ from the
|
|
24
|
+
member the type gates match on.
|
|
26
25
|
"""
|
|
27
26
|
|
|
28
27
|
def __init__(self, module: str) -> None:
|
|
29
28
|
self._module = module
|
|
30
29
|
self._members: Dict[str, str] = {}
|
|
30
|
+
self._bound: Set[str] = set()
|
|
31
31
|
self._locals = LocalBindings()
|
|
32
32
|
|
|
33
|
-
def scan(self, cu: CompilationUnit) -> None:
|
|
33
|
+
def scan(self, cu: CompilationUnit, cursor: Cursor) -> None:
|
|
34
34
|
"""Record the file's bindings; call from ``visit_compilation_unit``.
|
|
35
35
|
|
|
36
36
|
Top-level ``from`` statements only, since a guarded import's fallback may
|
|
@@ -48,6 +48,17 @@ class FromImports:
|
|
|
48
48
|
for imp in stmt.names:
|
|
49
49
|
name = get_qualid_name(imp.qualid)
|
|
50
50
|
self._members.setdefault(get_alias_name(imp) or name, name)
|
|
51
|
+
# A member this module already binds is one `maybe_add_import` reconciles.
|
|
52
|
+
self._bound = scope_of(cursor).names() - set(self._members)
|
|
53
|
+
|
|
54
|
+
def binds(self, name: str) -> bool:
|
|
55
|
+
"""Whether the module scope binds ``name`` outside this module's imports.
|
|
56
|
+
|
|
57
|
+
A replacement spelled unqualified resolves to the nearest module-scope
|
|
58
|
+
binding, so emitting one where something else holds the name redirects
|
|
59
|
+
the call rather than migrating it.
|
|
60
|
+
"""
|
|
61
|
+
return name in self._bound
|
|
51
62
|
|
|
52
63
|
def member_called(self, method: MethodInvocation, cursor: Cursor) -> Optional[str]:
|
|
53
64
|
"""The ``module`` member a receiver-less ``method`` calls, if it calls one."""
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Internal helpers for locating references to the typing module in a file."""
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Iterator, Optional, Sequence, Set, Tuple
|
|
4
|
+
|
|
5
|
+
from rewrite.java.support_types import Statement
|
|
6
|
+
from rewrite.java.tree import If, Import
|
|
7
|
+
from rewrite.python.import_utils import get_alias_name, get_name_string, get_qualid_name
|
|
8
|
+
from rewrite.python.remove_import import (
|
|
9
|
+
RemoveImportOptions,
|
|
10
|
+
maybe_remove_import,
|
|
11
|
+
unconditional_body,
|
|
12
|
+
)
|
|
13
|
+
from rewrite.python.tree import CompilationUnit, MultiImport
|
|
14
|
+
from rewrite.python.visitor import PythonVisitor
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _module_scope_statements(statements: Sequence[Statement]) -> Iterator[Statement]:
|
|
18
|
+
"""Every statement binding names in the module scope, `if` bodies included.
|
|
19
|
+
|
|
20
|
+
`if TYPE_CHECKING:` is where files that defer their annotations keep their
|
|
21
|
+
typing imports.
|
|
22
|
+
"""
|
|
23
|
+
for stmt in statements:
|
|
24
|
+
yield stmt
|
|
25
|
+
body = unconditional_body(stmt) if isinstance(stmt, If) else None
|
|
26
|
+
if body is not None:
|
|
27
|
+
yield from _module_scope_statements(body.statements)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def scan_typing_imports(cu: CompilationUnit) -> Tuple[Dict[str, str], Set[str]]:
|
|
31
|
+
"""Map how this file can reference typing members.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
A tuple of:
|
|
35
|
+
- exposed name -> typing member, for ``from typing import member [as alias]``
|
|
36
|
+
- the set of names bound to the typing module itself, for
|
|
37
|
+
``import typing [as alias]``
|
|
38
|
+
"""
|
|
39
|
+
members: Dict[str, str] = {}
|
|
40
|
+
module_refs: Set[str] = set()
|
|
41
|
+
for stmt in _module_scope_statements(cu.statements):
|
|
42
|
+
if isinstance(stmt, MultiImport):
|
|
43
|
+
if stmt.from_ is not None:
|
|
44
|
+
if get_name_string(stmt.from_) == "typing":
|
|
45
|
+
for imp in stmt.names:
|
|
46
|
+
name = get_qualid_name(imp.qualid)
|
|
47
|
+
members.setdefault(get_alias_name(imp) or name, name)
|
|
48
|
+
else:
|
|
49
|
+
for imp in stmt.names:
|
|
50
|
+
if get_qualid_name(imp.qualid) == "typing":
|
|
51
|
+
module_refs.add(get_alias_name(imp) or "typing")
|
|
52
|
+
elif isinstance(stmt, Import):
|
|
53
|
+
if get_qualid_name(stmt.qualid) == "typing":
|
|
54
|
+
module_refs.add(get_alias_name(stmt) or "typing")
|
|
55
|
+
return members, module_refs
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def maybe_remove_typing_import(visitor: PythonVisitor, name: Optional[str] = None) -> None:
|
|
59
|
+
"""Schedule removal of a typing import once it is no longer used."""
|
|
60
|
+
maybe_remove_import(visitor, RemoveImportOptions(module="typing", name=name))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def maybe_remove_typing_module_import(visitor: PythonVisitor, module_refs: Set[str]) -> None:
|
|
64
|
+
"""Schedule removal of `import typing` once it is no longer used.
|
|
65
|
+
|
|
66
|
+
RemoveImport's usage check counts `typing` identifiers, which an aliased
|
|
67
|
+
module import doesn't produce — removal is only scheduled when an
|
|
68
|
+
unaliased `import typing` exists.
|
|
69
|
+
"""
|
|
70
|
+
if "typing" in module_refs:
|
|
71
|
+
maybe_remove_typing_import(visitor)
|
|
@@ -115,7 +115,7 @@ class ReplaceGettextDeprecations(Recipe):
|
|
|
115
115
|
self._imports = FromImports("gettext")
|
|
116
116
|
|
|
117
117
|
def visit_compilation_unit(self, cu: CompilationUnit, p: ExecutionContext) -> J:
|
|
118
|
-
self._imports.scan(cu)
|
|
118
|
+
self._imports.scan(cu, self.cursor)
|
|
119
119
|
return super().visit_compilation_unit(cu, p)
|
|
120
120
|
|
|
121
121
|
def visit_method_invocation(
|
|
@@ -139,7 +139,7 @@ class ReplaceGettextDeprecations(Recipe):
|
|
|
139
139
|
# the import moves to the replacement along with the call.
|
|
140
140
|
member = self._imports.member_called(method, self.cursor)
|
|
141
141
|
new_name = GETTEXT_DEPRECATIONS.get(member) if member else None
|
|
142
|
-
if new_name is None:
|
|
142
|
+
if new_name is None or self._imports.binds(new_name):
|
|
143
143
|
return method
|
|
144
144
|
maybe_add_import(self, AddImportOptions(module="gettext", name=new_name))
|
|
145
145
|
maybe_remove_import(self, RemoveImportOptions(module="gettext", name=member))
|
|
@@ -153,7 +153,7 @@ class ReplaceLocaleResetlocale(Recipe):
|
|
|
153
153
|
self._imports = FromImports("locale")
|
|
154
154
|
|
|
155
155
|
def visit_compilation_unit(self, cu: CompilationUnit, p: ExecutionContext) -> J:
|
|
156
|
-
self._imports.scan(cu)
|
|
156
|
+
self._imports.scan(cu, self.cursor)
|
|
157
157
|
return super().visit_compilation_unit(cu, p)
|
|
158
158
|
|
|
159
159
|
def visit_method_invocation(
|
|
@@ -175,6 +175,8 @@ class ReplaceLocaleResetlocale(Recipe):
|
|
|
175
175
|
if self._imports.member_called(method, self.cursor) == "resetlocale":
|
|
176
176
|
# `setlocale` and `LC_ALL` are spelled unqualified, so each
|
|
177
177
|
# needs an import of its own.
|
|
178
|
+
if any(self._imports.binds(n) for n in ("setlocale", "LC_ALL")):
|
|
179
|
+
return method
|
|
178
180
|
for name in ("setlocale", "LC_ALL"):
|
|
179
181
|
maybe_add_import(self, AddImportOptions(module="locale", name=name))
|
|
180
182
|
maybe_remove_import(
|
|
@@ -93,7 +93,7 @@ class ReplacePlatformPopen(Recipe):
|
|
|
93
93
|
self._imports = FromImports("platform")
|
|
94
94
|
|
|
95
95
|
def visit_compilation_unit(self, cu: CompilationUnit, p: ExecutionContext) -> J:
|
|
96
|
-
self._imports.scan(cu)
|
|
96
|
+
self._imports.scan(cu, self.cursor)
|
|
97
97
|
return super().visit_compilation_unit(cu, p)
|
|
98
98
|
|
|
99
99
|
def visit_method_invocation(
|
|
@@ -92,7 +92,7 @@ class FindSslMatchHostname(Recipe):
|
|
|
92
92
|
self._imports = FromImports("ssl")
|
|
93
93
|
|
|
94
94
|
def visit_compilation_unit(self, cu: CompilationUnit, p: ExecutionContext) -> J:
|
|
95
|
-
self._imports.scan(cu)
|
|
95
|
+
self._imports.scan(cu, self.cursor)
|
|
96
96
|
return super().visit_compilation_unit(cu, p)
|
|
97
97
|
|
|
98
98
|
def visit_method_invocation(
|
|
@@ -20,14 +20,12 @@ handled with `ChangeImport` in `upgrade_to_python39`.
|
|
|
20
20
|
See: https://peps.python.org/pep-0585/
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
import ast
|
|
24
23
|
from typing import Any, ClassVar, Optional, Set, cast
|
|
25
24
|
|
|
26
25
|
from rewrite import ExecutionContext, Recipe, Tree, TreeVisitor
|
|
27
26
|
from rewrite.category import CategoryDescriptor
|
|
28
27
|
from rewrite.decorators import categorize
|
|
29
28
|
from rewrite.marketplace import Python
|
|
30
|
-
from rewrite.python.markers import Quoted
|
|
31
29
|
from rewrite.python.scope_utils import LocalBindings
|
|
32
30
|
from rewrite.visitor import Cursor
|
|
33
31
|
|
|
@@ -53,7 +51,6 @@ from rewrite.java.tree import (
|
|
|
53
51
|
Identifier,
|
|
54
52
|
Import,
|
|
55
53
|
J,
|
|
56
|
-
Literal,
|
|
57
54
|
ParameterizedType,
|
|
58
55
|
VariableDeclarations,
|
|
59
56
|
)
|
|
@@ -181,61 +178,13 @@ def _make_builtin_alias_editor(
|
|
|
181
178
|
|
|
182
179
|
result = cast(CompilationUnit, super().visit_compilation_unit(cu, p))
|
|
183
180
|
|
|
184
|
-
|
|
185
|
-
# RemoveImport's usage check; scanning the rewritten tree finds the
|
|
186
|
-
# ones that outlived the rename.
|
|
187
|
-
if self._bare_ref is not None and not self._forward_reference_survives(
|
|
188
|
-
result, self._bare_ref
|
|
189
|
-
):
|
|
181
|
+
if self._bare_ref is not None:
|
|
190
182
|
maybe_remove_typing_import(self, old_name)
|
|
191
183
|
if self._rewrote_qualified:
|
|
192
184
|
maybe_remove_typing_module_import(self, self._module_refs)
|
|
193
185
|
|
|
194
186
|
return result
|
|
195
187
|
|
|
196
|
-
@staticmethod
|
|
197
|
-
def _forward_reference_survives(cu: CompilationUnit, name: str) -> bool:
|
|
198
|
-
"""True when a string forward reference still names ``name``.
|
|
199
|
-
|
|
200
|
-
The parser leaves such a reference as text -- a string `Literal`
|
|
201
|
-
annotation, or an `Identifier` marked `Quoted` -- so its contents are
|
|
202
|
-
parsed as an expression. Prose that merely spells the name out, as a
|
|
203
|
-
docstring does, is not an expression and so is not a reference.
|
|
204
|
-
"""
|
|
205
|
-
found = False
|
|
206
|
-
|
|
207
|
-
def names_target(text: str) -> bool:
|
|
208
|
-
if name not in text:
|
|
209
|
-
return False
|
|
210
|
-
try:
|
|
211
|
-
parsed = ast.parse(text.strip(), mode="eval")
|
|
212
|
-
except (SyntaxError, ValueError):
|
|
213
|
-
return False
|
|
214
|
-
return any(
|
|
215
|
-
isinstance(node, ast.Name) and node.id == name
|
|
216
|
-
for node in ast.walk(parsed)
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
class ForwardReferenceScan(PythonVisitor[Any]):
|
|
220
|
-
def visit_literal(self, literal: Literal, p: Any) -> J:
|
|
221
|
-
nonlocal found
|
|
222
|
-
if not found and isinstance(literal.value, str) and names_target(literal.value):
|
|
223
|
-
found = True
|
|
224
|
-
return literal
|
|
225
|
-
|
|
226
|
-
def visit_identifier(self, ident: Identifier, p: Any) -> J:
|
|
227
|
-
nonlocal found
|
|
228
|
-
if (
|
|
229
|
-
not found
|
|
230
|
-
and ident.markers.find_first(Quoted) is not None
|
|
231
|
-
and names_target(ident.simple_name)
|
|
232
|
-
):
|
|
233
|
-
found = True
|
|
234
|
-
return ident
|
|
235
|
-
|
|
236
|
-
ForwardReferenceScan().visit(cu, None)
|
|
237
|
-
return found
|
|
238
|
-
|
|
239
188
|
def visit_field_access(self, field_access: FieldAccess, p: ExecutionContext) -> J:
|
|
240
189
|
if (
|
|
241
190
|
isinstance(field_access.target, Identifier)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openrewrite-migrate-python
|
|
3
|
-
Version: 0.14.0.
|
|
3
|
+
Version: 0.14.0.dev20260904170449
|
|
4
4
|
Summary: OpenRewrite recipes for migrating Python codebases to newer Python versions.
|
|
5
5
|
Author-email: "Moderne Inc." <support@moderne.io>
|
|
6
6
|
License: Moderne Proprietary
|
|
@@ -21,7 +21,7 @@ Classifier: Typing :: Typed
|
|
|
21
21
|
Requires-Python: >=3.10
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
Provides-Extra: dev
|
|
24
|
-
Requires-Dist: openrewrite>=8.91.
|
|
24
|
+
Requires-Dist: openrewrite>=8.91.5; extra == "dev"
|
|
25
25
|
Requires-Dist: pydantic>=2.11; extra == "dev"
|
|
26
26
|
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
27
27
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -100,3 +100,19 @@ class TestReplaceGettextDeprecations:
|
|
|
100
100
|
"""
|
|
101
101
|
)
|
|
102
102
|
)
|
|
103
|
+
|
|
104
|
+
def test_no_change_when_the_replacement_name_is_already_bound(self):
|
|
105
|
+
"""The added import would be shadowed by the file's own `gettext`."""
|
|
106
|
+
spec = RecipeSpec(recipe=ReplaceGettextDeprecations())
|
|
107
|
+
spec.rewrite_run(
|
|
108
|
+
python(
|
|
109
|
+
"""
|
|
110
|
+
from gettext import lgettext
|
|
111
|
+
|
|
112
|
+
def gettext(m):
|
|
113
|
+
return m
|
|
114
|
+
|
|
115
|
+
msg = lgettext("Hello")
|
|
116
|
+
"""
|
|
117
|
+
)
|
|
118
|
+
)
|
|
@@ -108,3 +108,47 @@ class TestReplaceLocaleResetlocale:
|
|
|
108
108
|
"""
|
|
109
109
|
)
|
|
110
110
|
)
|
|
111
|
+
|
|
112
|
+
def test_no_change_when_a_name_it_would_import_is_already_bound(self):
|
|
113
|
+
"""Either name, already bound, would capture the replacement's reference."""
|
|
114
|
+
spec = RecipeSpec(recipe=ReplaceLocaleResetlocale())
|
|
115
|
+
spec.rewrite_run(
|
|
116
|
+
python(
|
|
117
|
+
"""
|
|
118
|
+
from locale import resetlocale
|
|
119
|
+
|
|
120
|
+
def setlocale(*args):
|
|
121
|
+
return "mine"
|
|
122
|
+
|
|
123
|
+
resetlocale()
|
|
124
|
+
"""
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
spec.rewrite_run(
|
|
128
|
+
python(
|
|
129
|
+
"""
|
|
130
|
+
from locale import resetlocale
|
|
131
|
+
|
|
132
|
+
LC_ALL = "mine"
|
|
133
|
+
|
|
134
|
+
resetlocale()
|
|
135
|
+
"""
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
def test_rewrites_when_the_module_already_imports_the_replacement(self):
|
|
140
|
+
spec = RecipeSpec(recipe=ReplaceLocaleResetlocale())
|
|
141
|
+
spec.rewrite_run(
|
|
142
|
+
python(
|
|
143
|
+
"""
|
|
144
|
+
from locale import LC_ALL, resetlocale, setlocale
|
|
145
|
+
|
|
146
|
+
resetlocale()
|
|
147
|
+
""",
|
|
148
|
+
"""
|
|
149
|
+
from locale import LC_ALL, setlocale
|
|
150
|
+
|
|
151
|
+
setlocale(LC_ALL, "")
|
|
152
|
+
""",
|
|
153
|
+
)
|
|
154
|
+
)
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"""Internal helpers for locating references to the typing module in a file."""
|
|
2
|
-
|
|
3
|
-
from typing import Any, Dict, Iterator, List, Optional, Sequence, Set, Tuple, cast
|
|
4
|
-
|
|
5
|
-
from rewrite.java.support_types import JRightPadded, Space, Statement
|
|
6
|
-
from rewrite.java.tree import Block, If, Import, J
|
|
7
|
-
from rewrite.python.import_utils import get_alias_name, get_name_string, get_qualid_name
|
|
8
|
-
from rewrite.python.remove_import import RemoveImport, RemoveImportOptions, prefix_to_inherit
|
|
9
|
-
from rewrite.python.tree import CompilationUnit, MultiImport
|
|
10
|
-
from rewrite.python.visitor import PythonVisitor
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def _module_scope_statements(statements: Sequence[Statement]) -> Iterator[Statement]:
|
|
14
|
-
"""Every statement binding names in the module scope, `if` bodies included.
|
|
15
|
-
|
|
16
|
-
`if TYPE_CHECKING:` is where files that defer their annotations keep their
|
|
17
|
-
typing imports.
|
|
18
|
-
"""
|
|
19
|
-
for stmt in statements:
|
|
20
|
-
yield stmt
|
|
21
|
-
body = _unconditional_body(stmt) if isinstance(stmt, If) else None
|
|
22
|
-
if body is not None:
|
|
23
|
-
yield from _module_scope_statements(body.statements)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def _unconditional_body(if_: If) -> Optional[Block]:
|
|
27
|
-
"""The body of an `if` that only adds bindings to the enclosing scope.
|
|
28
|
-
|
|
29
|
-
None once there is an `else`: the branches are then alternative bindings of
|
|
30
|
-
the same name, and honouring one would rewrite the other's binding too.
|
|
31
|
-
"""
|
|
32
|
-
then_part = if_.then_part
|
|
33
|
-
return then_part if if_.else_part is None and isinstance(then_part, Block) else None
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def scan_typing_imports(cu: CompilationUnit) -> Tuple[Dict[str, str], Set[str]]:
|
|
37
|
-
"""Map how this file can reference typing members.
|
|
38
|
-
|
|
39
|
-
Returns:
|
|
40
|
-
A tuple of:
|
|
41
|
-
- exposed name -> typing member, for ``from typing import member [as alias]``
|
|
42
|
-
- the set of names bound to the typing module itself, for
|
|
43
|
-
``import typing [as alias]``
|
|
44
|
-
"""
|
|
45
|
-
members: Dict[str, str] = {}
|
|
46
|
-
module_refs: Set[str] = set()
|
|
47
|
-
for stmt in _module_scope_statements(cu.statements):
|
|
48
|
-
if isinstance(stmt, MultiImport):
|
|
49
|
-
if stmt.from_ is not None:
|
|
50
|
-
if get_name_string(stmt.from_) == "typing":
|
|
51
|
-
for imp in stmt.names:
|
|
52
|
-
name = get_qualid_name(imp.qualid)
|
|
53
|
-
members.setdefault(get_alias_name(imp) or name, name)
|
|
54
|
-
else:
|
|
55
|
-
for imp in stmt.names:
|
|
56
|
-
if get_qualid_name(imp.qualid) == "typing":
|
|
57
|
-
module_refs.add(get_alias_name(imp) or "typing")
|
|
58
|
-
elif isinstance(stmt, Import):
|
|
59
|
-
if get_qualid_name(stmt.qualid) == "typing":
|
|
60
|
-
module_refs.add(get_alias_name(stmt) or "typing")
|
|
61
|
-
return members, module_refs
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def maybe_remove_typing_import(visitor: PythonVisitor, name: Optional[str] = None) -> None:
|
|
65
|
-
"""Schedule removal of a typing import once it is no longer used.
|
|
66
|
-
|
|
67
|
-
Mirrors the SDK's `maybe_remove_import`, registering the block-aware visitor.
|
|
68
|
-
"""
|
|
69
|
-
options = RemoveImportOptions(module="typing", name=name)
|
|
70
|
-
if visitor._after_visit is None:
|
|
71
|
-
visitor._after_visit = []
|
|
72
|
-
for scheduled in visitor._after_visit:
|
|
73
|
-
# Only this visitor counts as already scheduled: a plain `RemoveImport`
|
|
74
|
-
# for the same name reaches the top level alone, and would leave the
|
|
75
|
-
# nested imports this exists to remove.
|
|
76
|
-
if (
|
|
77
|
-
type(scheduled) is _RemoveImportInBlocks
|
|
78
|
-
and scheduled.module == options.module
|
|
79
|
-
and scheduled.name == options.name
|
|
80
|
-
):
|
|
81
|
-
return
|
|
82
|
-
visitor._after_visit.append(_RemoveImportInBlocks(options))
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def maybe_remove_typing_module_import(visitor: PythonVisitor, module_refs: Set[str]) -> None:
|
|
86
|
-
"""Schedule removal of `import typing` once it is no longer used.
|
|
87
|
-
|
|
88
|
-
RemoveImport's usage check counts `typing` identifiers, which an aliased
|
|
89
|
-
module import doesn't produce — removal is only scheduled when an
|
|
90
|
-
unaliased `import typing` exists.
|
|
91
|
-
"""
|
|
92
|
-
if "typing" in module_refs:
|
|
93
|
-
maybe_remove_typing_import(visitor)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
class _RemoveImportInBlocks(RemoveImport):
|
|
97
|
-
"""`RemoveImport` extended to imports inside module-scope `if` bodies.
|
|
98
|
-
|
|
99
|
-
The base visitor prunes only the file's top-level statement list.
|
|
100
|
-
"""
|
|
101
|
-
|
|
102
|
-
def visit_compilation_unit(self, cu: CompilationUnit, p: Any) -> J:
|
|
103
|
-
cu = cast(CompilationUnit, super().visit_compilation_unit(cu, p))
|
|
104
|
-
kept = self._prune(cu.padding.statements, prune_imports=False)
|
|
105
|
-
return cu if kept is None else cu.padding.replace(_statements=kept)
|
|
106
|
-
|
|
107
|
-
def _prune(
|
|
108
|
-
self, padded_statements: Sequence[JRightPadded], prune_imports: bool
|
|
109
|
-
) -> Optional[List[JRightPadded]]:
|
|
110
|
-
"""The statements with the import gone, or None when nothing changed."""
|
|
111
|
-
kept: List[JRightPadded] = []
|
|
112
|
-
inherited: Optional[Space] = None
|
|
113
|
-
changed = False
|
|
114
|
-
for index, padded in enumerate(padded_statements):
|
|
115
|
-
stmt = padded.element
|
|
116
|
-
if isinstance(stmt, If):
|
|
117
|
-
result: Optional[Statement] = self._prune_if(stmt)
|
|
118
|
-
elif prune_imports and isinstance(stmt, MultiImport):
|
|
119
|
-
result = self._process_multi_import(stmt)
|
|
120
|
-
elif prune_imports and isinstance(stmt, Import):
|
|
121
|
-
result = self._process_single_import(stmt)
|
|
122
|
-
else:
|
|
123
|
-
result = stmt
|
|
124
|
-
|
|
125
|
-
if result is None:
|
|
126
|
-
changed = True
|
|
127
|
-
if inherited is None:
|
|
128
|
-
inherited = prefix_to_inherit(stmt, index)
|
|
129
|
-
continue
|
|
130
|
-
if result is not stmt:
|
|
131
|
-
padded = JRightPadded(result, padded.after, padded.markers)
|
|
132
|
-
changed = True
|
|
133
|
-
if inherited is not None:
|
|
134
|
-
if not padded.element.prefix.comments:
|
|
135
|
-
padded = JRightPadded(
|
|
136
|
-
padded.element.replace(prefix=inherited), padded.after, padded.markers
|
|
137
|
-
)
|
|
138
|
-
elif inherited.comments:
|
|
139
|
-
# Neither comment can be given up, and one prefix holds both.
|
|
140
|
-
return None
|
|
141
|
-
inherited = None
|
|
142
|
-
kept.append(padded)
|
|
143
|
-
# A leftover prefix means nothing followed the removal to carry it, so a
|
|
144
|
-
# comment on the removed statement would be dropped with it.
|
|
145
|
-
if inherited is not None and inherited.comments:
|
|
146
|
-
return None
|
|
147
|
-
return kept if changed else None
|
|
148
|
-
|
|
149
|
-
def _prune_if(self, if_: If) -> Optional[If]:
|
|
150
|
-
"""`if_` with the import gone from its body, or None once that empties it."""
|
|
151
|
-
then_part = _unconditional_body(if_)
|
|
152
|
-
if then_part is None:
|
|
153
|
-
return if_
|
|
154
|
-
kept = self._prune(then_part.padding.statements, prune_imports=True)
|
|
155
|
-
if kept is None:
|
|
156
|
-
return if_
|
|
157
|
-
if not kept:
|
|
158
|
-
return None
|
|
159
|
-
padded = if_.padding.then_part
|
|
160
|
-
return if_.padding.replace(
|
|
161
|
-
_then_part=JRightPadded(
|
|
162
|
-
then_part.padding.replace(_statements=kept), padded.after, padded.markers
|
|
163
|
-
)
|
|
164
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|