openrewrite-migrate-python 0.17.0.dev20261020170647__tar.gz → 0.17.0.dev20261021134401__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.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/PKG-INFO +1 -1
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/pyproject.toml +1 -1
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/attr_access.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/boolean_simplification.py +8 -8
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/collection_literals.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/complex_transforms.py +5 -5
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/comprehension_cleanup.py +4 -4
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/conditionals.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/dict_cleanup.py +4 -4
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/exception_cleanup.py +3 -3
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/expression_simplification.py +3 -3
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/loop_cleanup.py +3 -3
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/naming_conventions.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/string_cleanup.py +6 -6
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/unreachable_code.py +4 -4
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/use_items.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/_reindent.py +3 -3
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/_semantically_equal.py +3 -3
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/_trivia.py +5 -5
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/all_branches_identical.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/find_suspicious_chained_comparison.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/remove_duplicate_conditions.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/remove_self_assignment.py +4 -4
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/remove_unconditional_value_overwrite.py +5 -5
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/simplify_boolean_literal.py +3 -3
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/__init__.py +2 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/_markers.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/_module_imports.py +4 -4
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/backoff_to_tenacity.py +47 -47
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/datetime_utc.py +4 -4
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/langchain_community_imports.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/locale_getdefaultlocale_deprecation.py +4 -5
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/pydantic_deprecations.py +5 -5
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/string_formatting.py +9 -9
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/typing_deprecations.py +4 -4
- openrewrite_migrate_python-0.17.0.dev20261021134401/src/openrewrite_migrate_python/migrate/upgrade_to_python315.py +55 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_python39.py +2 -2
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python.egg-info/PKG-INFO +1 -1
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python.egg-info/SOURCES.txt +1 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_upgrade_recipes.py +16 -3
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/setup.cfg +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/__init__.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/__init__.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/_literals.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/assign_return.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/comparison_simplification.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/datetime_cleanup.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/logger_warn.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/merge_nested_with.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/merge_startswith_endswith.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/negated_operators.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/none_and_identity.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/object_inheritance.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/pandas_cleanup.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/python_best_practices.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/range_cleanup.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/redundant_code.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/remove_trailing_return_none.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/use_list_clear.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/cleanup/yoda_conditions.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/__init__.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/_side_effects.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/_truth_value.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/boolean_checks_not_inverted.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/code_quality.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/collapsible_if_statements.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/merge_identical_branches.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_code_quality_python/codequality/simplify_redundant_logical_expression.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/__init__.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/_decorators.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/_langchain_tables.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/_method_renames.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/_slots.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/aifc_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/array_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/ast_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/asyncio_coroutine_to_async.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/asyncio_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/avro_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/calendar_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/cgi_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/cgi_parse_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/collections_abc_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/configparser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/distutils_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/distutils_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/functools_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/future_imports.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/gettext_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/html_parser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/imp_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/langchain_classic_imports.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/langchain_provider_imports.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/locale_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/macpath_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/mailcap_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/nntplib_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/os_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/pathlib_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/pep594_system_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/pipes_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/pkgutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/platform_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/pydantic_fields.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/pydantic_model_fields.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/re_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/removed_modules_312.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/shutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/socket_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/ssl_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/sys_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/sys_last_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/tarfile_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/telnetlib_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/tempfile_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/threading_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/threading_is_alive_deprecation.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/typing_callable.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/typing_union_to_pipe.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/unittest_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_langchain02.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_langchain1.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_pandas.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_pydantic.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_python310.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_python311.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_python312.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_python313.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_python314.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/upgrade_to_python38.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/urllib_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/uu_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/xdrlib_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python/migrate/xml_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python.egg-info/dependency_links.txt +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python.egg-info/entry_points.txt +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python.egg-info/requires.txt +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/src/openrewrite_migrate_python.egg-info/top_level.txt +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_aifc_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_array_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_ast_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_asyncio_coroutine_to_async.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_asyncio_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_avro_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_backoff_to_tenacity.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_calendar_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_cgi_parse_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_change_import_recipes.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_collections_abc_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_configparser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_datetime_utc.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_distutils_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_distutils_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_functools_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_future_imports.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_gettext_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_html_parser_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_imp_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_langchain_classic_imports.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_langchain_community_imports.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_langchain_provider_imports.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_locale_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_locale_getdefaultlocale_deprecation.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_macpath_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_mailcap_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_markers.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_os_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_pathlib_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_pep594_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_pep594_system_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_pkgutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_platform_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_pydantic_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_pydantic_fields.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_pydantic_model_fields.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_re_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_removed_modules_312.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_shutil_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_socket_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_ssl_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_string_formatting.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_sys_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_sys_last_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_tarfile_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_tempfile_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_threading_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_threading_extended.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_threading_is_alive_deprecation.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_typing_alias_moves.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_typing_callable.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_typing_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_typing_union_to_pipe.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_unittest_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_upgrade_to_pydantic.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_urllib_deprecations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/tests/test_xdrlib_migrations.py +0 -0
- {openrewrite_migrate_python-0.17.0.dev20261020170647 → openrewrite_migrate_python-0.17.0.dev20261021134401}/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.17.0.
|
|
3
|
+
Version: 0.17.0.dev20261021134401
|
|
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
|
|
@@ -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.17.0.
|
|
8
|
+
version = "0.17.0.dev20261021134401" # 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"
|
|
@@ -12,7 +12,7 @@ See:
|
|
|
12
12
|
|
|
13
13
|
import keyword
|
|
14
14
|
from functools import lru_cache
|
|
15
|
-
from typing import Any, List
|
|
15
|
+
from typing import Any, List
|
|
16
16
|
|
|
17
17
|
from rewrite import ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
18
18
|
from rewrite.category import CategoryDescriptor
|
|
@@ -56,7 +56,7 @@ def _assignment_template(attr_name: str) -> Template:
|
|
|
56
56
|
return template(f"{_obj}.{attr_name} = {_val}")
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
def _constant_attribute_name(method: MethodInvocation) ->
|
|
59
|
+
def _constant_attribute_name(method: MethodInvocation) -> str | None:
|
|
60
60
|
"""The attribute name a builtin ``getattr``/``setattr`` call spells as a literal,
|
|
61
61
|
when attribute syntax reads the same attribute."""
|
|
62
62
|
attr_arg = method.arguments[1]
|
|
@@ -15,7 +15,7 @@ See: https://peps.python.org/pep-0008/#programming-recommendations
|
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
17
|
import uuid
|
|
18
|
-
from typing import Any, List
|
|
18
|
+
from typing import Any, List
|
|
19
19
|
|
|
20
20
|
from rewrite import ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
21
21
|
from rewrite.markers import Markers
|
|
@@ -120,7 +120,7 @@ _FLIP_OPS = {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
def _flip_py_binary(expr) ->
|
|
123
|
+
def _flip_py_binary(expr) -> PyBinary | None:
|
|
124
124
|
"""Flip a membership/identity operator: ``in`` ↔ ``not in``, ``is`` ↔ ``is not``.
|
|
125
125
|
|
|
126
126
|
Returns the flipped :class:`PyBinary`, or ``None`` if the expression is
|
|
@@ -155,7 +155,7 @@ _as_bool_cond = capture('cond')
|
|
|
155
155
|
_bool_template = template("bool({cond})", cond=_as_bool_cond)
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
def _as_bool(cond: Expression, cursor: Cursor) ->
|
|
158
|
+
def _as_bool(cond: Expression, cursor: Cursor) -> Expression | None:
|
|
159
159
|
"""``cond`` as a bool-valued expression replacing ``cursor``'s node, or None.
|
|
160
160
|
|
|
161
161
|
None where the call would have to be to a ``bool`` that is not the builtin.
|
|
@@ -485,7 +485,7 @@ class DeMorgan(Recipe):
|
|
|
485
485
|
return Visitor()
|
|
486
486
|
|
|
487
487
|
|
|
488
|
-
def _is_sized_builtin(type_:
|
|
488
|
+
def _is_sized_builtin(type_: JavaType | None) -> bool:
|
|
489
489
|
return type_ is JavaType.Primitive.String or any(
|
|
490
490
|
is_of_class_type(type_, name) for name in _SIZED_CLASSES
|
|
491
491
|
)
|
|
@@ -569,7 +569,7 @@ class SimplifyLenComparison(Recipe):
|
|
|
569
569
|
return Preconditions.check(uses_method(_LEN_PATTERN), Visitor())
|
|
570
570
|
|
|
571
571
|
|
|
572
|
-
def _is_collection_literal(node) ->
|
|
572
|
+
def _is_collection_literal(node) -> bool | None:
|
|
573
573
|
"""
|
|
574
574
|
Check if a node is a collection literal and return whether it's non-empty.
|
|
575
575
|
|
|
@@ -708,7 +708,7 @@ class CollectionToBool(Recipe):
|
|
|
708
708
|
return Visitor()
|
|
709
709
|
|
|
710
710
|
|
|
711
|
-
def _returned_bool(stmt) ->
|
|
711
|
+
def _returned_bool(stmt) -> bool | None:
|
|
712
712
|
"""The literal a `return True`/`return False` statement returns, else None."""
|
|
713
713
|
if isinstance(stmt, Return):
|
|
714
714
|
expr = stmt.expression
|
|
@@ -767,7 +767,7 @@ class SimplifyBooleanReturn(Recipe):
|
|
|
767
767
|
def editor(self) -> TreeVisitor[Any, ExecutionContext]:
|
|
768
768
|
class Visitor(PythonVisitor[ExecutionContext]):
|
|
769
769
|
|
|
770
|
-
def _get_single_bool_return(self, body) ->
|
|
770
|
+
def _get_single_bool_return(self, body) -> bool | None:
|
|
771
771
|
"""If body is a Block holding only `return True`/`return False`, that literal."""
|
|
772
772
|
if not isinstance(body, Block) or len(body.statements) != 1:
|
|
773
773
|
return None
|
|
@@ -827,7 +827,7 @@ class SimplifyBooleanReturn(Recipe):
|
|
|
827
827
|
|
|
828
828
|
def _simplify_return(
|
|
829
829
|
self, if_: JIf, parent: Cursor, then_is_true: bool, else_is_true: bool
|
|
830
|
-
) ->
|
|
830
|
+
) -> Return | None:
|
|
831
831
|
"""Build Return for the simplified boolean pattern."""
|
|
832
832
|
cond = self._unwrap_condition(if_.if_condition)
|
|
833
833
|
if then_is_true and not else_is_true:
|
|
@@ -16,7 +16,7 @@ Other collection-related recipes in this module:
|
|
|
16
16
|
See: https://docs.quantifiedcode.com/python-anti-patterns/performance/using_key_in_list_to_check_if_key_is_contained_in_a_list.html
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
from typing import Any, List
|
|
19
|
+
from typing import Any, List
|
|
20
20
|
|
|
21
21
|
from rewrite import ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
22
22
|
from rewrite.category import CategoryDescriptor
|
|
@@ -291,7 +291,7 @@ _UNWRAP_TARGET_KIND = {
|
|
|
291
291
|
_UNWRAP_MATCHERS = [(MethodMatcher.create(p), kind) for p, kind in _UNWRAP_TARGET_KIND.items()]
|
|
292
292
|
|
|
293
293
|
|
|
294
|
-
def _literal_type(call: MethodInvocation, kind: CollectionLiteral.Kind) ->
|
|
294
|
+
def _literal_type(call: MethodInvocation, kind: CollectionLiteral.Kind) -> JavaType | None:
|
|
295
295
|
"""The call's type where it names the literal's class, as ``set(...)``'s does, else None."""
|
|
296
296
|
return call.type if is_of_class_type(call.type, kind.name.lower()) else None
|
|
297
297
|
|
|
@@ -6,7 +6,7 @@ Recipes that simplify or correct multi-statement and compound-expression idioms.
|
|
|
6
6
|
- SwapVariable: Collapse a three-line temp-variable swap into tuple unpacking
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
from typing import Any, List
|
|
9
|
+
from typing import Any, List
|
|
10
10
|
|
|
11
11
|
from rewrite import Cursor, ExecutionContext, Recipe, TreeVisitor
|
|
12
12
|
from rewrite.category import CategoryDescriptor
|
|
@@ -110,14 +110,14 @@ class TernaryToIfExpression(Recipe):
|
|
|
110
110
|
return Visitor()
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
def _is_simple_identifier(expr: Any) ->
|
|
113
|
+
def _is_simple_identifier(expr: Any) -> str | None:
|
|
114
114
|
"""Return the simple name if the expression is a plain Identifier, else None."""
|
|
115
115
|
if isinstance(expr, Identifier):
|
|
116
116
|
return expr.simple_name
|
|
117
117
|
return None
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
def _enclosing_function(cursor: Cursor) ->
|
|
120
|
+
def _enclosing_function(cursor: Cursor) -> MethodDeclaration | None:
|
|
121
121
|
"""The function whose local scope the block at ``cursor`` runs in, if any."""
|
|
122
122
|
for value in cursor.get_path():
|
|
123
123
|
if isinstance(value, MethodDeclaration):
|
|
@@ -129,7 +129,7 @@ def _enclosing_function(cursor: Cursor) -> Optional[MethodDeclaration]:
|
|
|
129
129
|
|
|
130
130
|
def _find_swap_pattern(
|
|
131
131
|
stmts: List[JRightPadded], method: MethodDeclaration
|
|
132
|
-
) ->
|
|
132
|
+
) -> tuple | None:
|
|
133
133
|
"""Find a 3-statement swap pattern in a list of padded statements.
|
|
134
134
|
|
|
135
135
|
Looks for: temp = a; a = b; b = temp
|
|
@@ -231,7 +231,7 @@ class SwapVariable(Recipe):
|
|
|
231
231
|
|
|
232
232
|
def _transform_stmts(
|
|
233
233
|
self, stmts: List[JRightPadded], method: MethodDeclaration
|
|
234
|
-
) ->
|
|
234
|
+
) -> List[JRightPadded] | None:
|
|
235
235
|
result = _find_swap_pattern(stmts, method)
|
|
236
236
|
if result is None:
|
|
237
237
|
return None
|
|
@@ -21,7 +21,7 @@ and identity generators passed to aggregation functions like ``any()``/``all()``
|
|
|
21
21
|
can typically be replaced by passing the iterable directly.
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
|
-
from typing import Any, Dict, FrozenSet, List
|
|
24
|
+
from typing import Any, Dict, FrozenSet, List
|
|
25
25
|
|
|
26
26
|
from rewrite import Cursor, ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
27
27
|
from rewrite.category import CategoryDescriptor
|
|
@@ -115,7 +115,7 @@ _bool_template = template('bool({x})', x=_x_capture)
|
|
|
115
115
|
|
|
116
116
|
def _builtin_call(
|
|
117
117
|
method: MethodInvocation, cursor: Cursor, names: FrozenSet[str]
|
|
118
|
-
) ->
|
|
118
|
+
) -> str | None:
|
|
119
119
|
"""The name of the builtin in ``names`` that ``method`` calls, if it calls one."""
|
|
120
120
|
name = method.name.simple_name
|
|
121
121
|
if name in names and _BUILTINS[name].matches(method, cursor=cursor):
|
|
@@ -299,7 +299,7 @@ class SimplifyGenerator(Recipe):
|
|
|
299
299
|
return Preconditions.check(_uses_builtins("any", "all"), Visitor())
|
|
300
300
|
|
|
301
301
|
|
|
302
|
-
def _get_single_generator(method: MethodInvocation) ->
|
|
302
|
+
def _get_single_generator(method: MethodInvocation) -> ComprehensionExpression | None:
|
|
303
303
|
"""Return the single generator argument if there is exactly one, else None."""
|
|
304
304
|
args = method.arguments
|
|
305
305
|
if len(args) != 1 or not isinstance(args[0], ComprehensionExpression):
|
|
@@ -370,7 +370,7 @@ def _without_bracket_lines(comp: ComprehensionExpression, after: Space) -> Compr
|
|
|
370
370
|
return comp
|
|
371
371
|
|
|
372
372
|
|
|
373
|
-
def _get_single_list_comp(method: MethodInvocation) ->
|
|
373
|
+
def _get_single_list_comp(method: MethodInvocation) -> ComprehensionExpression | None:
|
|
374
374
|
"""Return the single list-comprehension argument if there is exactly one, else None."""
|
|
375
375
|
args = method.arguments
|
|
376
376
|
if len(args) != 1 or not isinstance(args[0], ComprehensionExpression):
|
|
@@ -10,7 +10,7 @@ Recipes that simplify and tighten conditional logic.
|
|
|
10
10
|
- Condense matching if/else assignments into a single ternary expression (AssignIfExp)
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import Any, List
|
|
13
|
+
from typing import Any, List
|
|
14
14
|
|
|
15
15
|
from rewrite import ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
16
16
|
from rewrite.category import CategoryDescriptor
|
|
@@ -110,7 +110,7 @@ def _pass_has_comments(if_stmt: JIf) -> bool:
|
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
class _LineBreakFinder(PythonVisitor[List[bool]]):
|
|
113
|
-
def visit_space(self, space:
|
|
113
|
+
def visit_space(self, space: Space | None, p: List[bool]) -> Any:
|
|
114
114
|
if space is not None and ("\n" in space.whitespace or any("\n" in c.suffix for c in space.comments)):
|
|
115
115
|
p.append(True)
|
|
116
116
|
return space
|
|
@@ -9,7 +9,7 @@ Recipes that simplify and improve dictionary and set usage.
|
|
|
9
9
|
- ``RemoveDuplicateSetKey``: Clean up repeated values in set display literals.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
from typing import Any, Dict, List,
|
|
12
|
+
from typing import Any, Dict, List, Set
|
|
13
13
|
|
|
14
14
|
from rewrite import Cursor, ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
15
15
|
from rewrite.category import CategoryDescriptor
|
|
@@ -63,11 +63,11 @@ _DICT_CONSTRUCTOR = MethodMatcher.create(_DICT_CONSTRUCTOR_PATTERN)
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
# Exact, so a subclass such as `Counter` with its own `update`, `keys` or `|` is excluded.
|
|
66
|
-
def _is_dict(expr:
|
|
66
|
+
def _is_dict(expr: J | None) -> bool:
|
|
67
67
|
return isinstance(expr, Expression) and is_of_class_type(expr.type, "dict")
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
def _expr_key(expr: J) ->
|
|
70
|
+
def _expr_key(expr: J) -> str | None:
|
|
71
71
|
"""A key that equal identifiers and literals share, or None for anything else."""
|
|
72
72
|
if isinstance(expr, Identifier):
|
|
73
73
|
return f"id:{expr.simple_name}"
|
|
@@ -418,7 +418,7 @@ class RemoveRedundantConstructorInDictUnion(Recipe):
|
|
|
418
418
|
|
|
419
419
|
def editor(self) -> TreeVisitor[Any, ExecutionContext]:
|
|
420
420
|
class Visitor(PythonVisitor[ExecutionContext]):
|
|
421
|
-
def _unwrap_dict(self, node: Expression) ->
|
|
421
|
+
def _unwrap_dict(self, node: Expression) -> Expression | None:
|
|
422
422
|
"""If node is the builtin ``dict(x)`` copying the dict ``x``, return x."""
|
|
423
423
|
if not isinstance(node, MethodInvocation) or node.select is not None:
|
|
424
424
|
return None
|
|
@@ -6,7 +6,7 @@ Recipes that improve exception handling hygiene.
|
|
|
6
6
|
- Chain exceptions raised in an ``except`` block to the caught one with ``from``.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
from typing import Any, List,
|
|
9
|
+
from typing import Any, List, Tuple
|
|
10
10
|
from uuid import uuid4
|
|
11
11
|
|
|
12
12
|
from rewrite import Cursor, ExecutionContext, Markers, Recipe, TreeVisitor
|
|
@@ -140,7 +140,7 @@ def _is_dotted_name(expr: Expression) -> bool:
|
|
|
140
140
|
return isinstance(expr, Identifier)
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
def _handler_name(cursor: Cursor) ->
|
|
143
|
+
def _handler_name(cursor: Cursor) -> Tuple[Identifier, Try.Catch] | None:
|
|
144
144
|
"""The name the nearest enclosing ``except`` binds and that handler, if a raise there may chain from it.
|
|
145
145
|
|
|
146
146
|
The name is unbound once the handler exits, so a raise inside a nested
|
|
@@ -159,7 +159,7 @@ def _handler_name(cursor: Cursor) -> Optional[Tuple[Identifier, Try.Catch]]:
|
|
|
159
159
|
return None
|
|
160
160
|
|
|
161
161
|
|
|
162
|
-
def _caught_type(catch: Try.Catch) ->
|
|
162
|
+
def _caught_type(catch: Try.Catch) -> JavaType | None:
|
|
163
163
|
"""The type a parse gives a reference to the name ``catch`` binds."""
|
|
164
164
|
type_expression = catch.parameter.tree.type_expression
|
|
165
165
|
if not isinstance(type_expression, ExceptionType):
|
|
@@ -8,7 +8,7 @@ Recipes that tighten common Python expression patterns.
|
|
|
8
8
|
- Shorten ``x = x + y`` to ``x += y`` on immutable builtins (AugAssign)
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
from typing import Any, List
|
|
11
|
+
from typing import Any, List
|
|
12
12
|
|
|
13
13
|
from rewrite import Cursor, ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
14
14
|
from rewrite.category import CategoryDescriptor
|
|
@@ -54,14 +54,14 @@ _IMMUTABLE_PRIMITIVES = (
|
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def _is_builtin_sequence(type_:
|
|
57
|
+
def _is_builtin_sequence(type_: JavaType | None) -> bool:
|
|
58
58
|
"""Whether ``type_`` is a builtin sequence, whose slicing and negative indexing are known."""
|
|
59
59
|
return is_string(type_) or any(
|
|
60
60
|
is_of_class_type(type_, fqn) for fqn in ("list", "tuple", "range", "bytearray")
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def _is_immutable(type_:
|
|
64
|
+
def _is_immutable(type_: JavaType | None) -> bool:
|
|
65
65
|
"""Whether ``type_`` is a builtin with no in-place operators, so ``x op= y`` rebinds ``x``."""
|
|
66
66
|
if isinstance(type_, JavaType.Union):
|
|
67
67
|
return all(_is_immutable(t) for t in type_.bounds)
|
|
@@ -5,7 +5,7 @@ Recipes that simplify and modernize loop constructs.
|
|
|
5
5
|
so it can be placed after the loop without the else keyword.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from typing import Any, List
|
|
8
|
+
from typing import Any, List
|
|
9
9
|
|
|
10
10
|
from rewrite import ExecutionContext, Recipe, TreeVisitor
|
|
11
11
|
from rewrite.category import CategoryDescriptor
|
|
@@ -58,7 +58,7 @@ def _has_break(tree: J) -> bool:
|
|
|
58
58
|
return checker.found
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
def _else_body(wrapper: TrailingElseWrapper) ->
|
|
61
|
+
def _else_body(wrapper: TrailingElseWrapper) -> List[JRightPadded[Statement]] | None:
|
|
62
62
|
"""The else body re-indented to the loop's level, or None where it cannot move cleanly.
|
|
63
63
|
|
|
64
64
|
Comments around the `else:` header have no line of their own to move to.
|
|
@@ -84,7 +84,7 @@ def _else_body(wrapper: TrailingElseWrapper) -> Optional[List[JRightPadded[State
|
|
|
84
84
|
|
|
85
85
|
def _flatten_useless_else(
|
|
86
86
|
stmts_padded: List[JRightPadded[Statement]],
|
|
87
|
-
) ->
|
|
87
|
+
) -> List[JRightPadded[Statement]] | None:
|
|
88
88
|
"""Process a statement list, flattening useless else on for loops.
|
|
89
89
|
|
|
90
90
|
Returns a new list if any changes were made, or None if unchanged.
|
|
@@ -16,7 +16,7 @@ See: https://peps.python.org/pep-0008/#function-and-method-arguments
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
import dataclasses
|
|
19
|
-
from typing import Any, Callable, List
|
|
19
|
+
from typing import Any, Callable, List
|
|
20
20
|
|
|
21
21
|
from rewrite import Cursor, ExecutionContext, Recipe, TreeVisitor
|
|
22
22
|
from rewrite.category import CategoryDescriptor
|
|
@@ -61,7 +61,7 @@ def _is_directly_in_class_body(cursor: Cursor) -> bool:
|
|
|
61
61
|
return False
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def _first_param(method: MethodDeclaration) ->
|
|
64
|
+
def _first_param(method: MethodDeclaration) -> Identifier | None:
|
|
65
65
|
params = method.parameters
|
|
66
66
|
if not params:
|
|
67
67
|
return None
|
|
@@ -12,7 +12,7 @@ Recipes that clean up unnecessary string and formatting constructs.
|
|
|
12
12
|
- ``UseStringRemoveAffix``: rewrite a guarded slice as ``removeprefix``/``removesuffix``
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
from typing import Any, List
|
|
15
|
+
from typing import Any, List
|
|
16
16
|
|
|
17
17
|
from rewrite import ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
18
18
|
from rewrite.category import CategoryDescriptor
|
|
@@ -90,7 +90,7 @@ def _is_str(expr: Expression) -> bool:
|
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
def _get_literal_string_len(expr: Any) ->
|
|
93
|
+
def _get_literal_string_len(expr: Any) -> int | None:
|
|
94
94
|
"""If expr is a string Literal, return the length of its string value."""
|
|
95
95
|
if not is_string_literal(expr):
|
|
96
96
|
return None
|
|
@@ -104,7 +104,7 @@ def _has_step(slc: Slice) -> bool:
|
|
|
104
104
|
return slc.step is not None and not isinstance(slc.step, Empty)
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
def _get_int_value(expr: Any) ->
|
|
107
|
+
def _get_int_value(expr: Any) -> int | None:
|
|
108
108
|
"""Get integer value from a Literal or Unary(Negative, Literal)."""
|
|
109
109
|
if isinstance(expr, Literal) and isinstance(expr.value, int):
|
|
110
110
|
return expr.value
|
|
@@ -511,8 +511,8 @@ class StrPrefixSuffix(Recipe):
|
|
|
511
511
|
right = binary.right
|
|
512
512
|
|
|
513
513
|
# Determine which side is the slice and which is the string
|
|
514
|
-
slice_side:
|
|
515
|
-
string_side:
|
|
514
|
+
slice_side: ArrayAccess | None = None
|
|
515
|
+
string_side: Expression | None = None
|
|
516
516
|
if isinstance(left, ArrayAccess) and isinstance(left.dimension.index, Slice):
|
|
517
517
|
slice_side = left
|
|
518
518
|
string_side = right
|
|
@@ -621,7 +621,7 @@ class UseGetitemForReMatchGroups(Recipe):
|
|
|
621
621
|
_NOT_INLINABLE = set('{}\'"\\\n\r')
|
|
622
622
|
|
|
623
623
|
|
|
624
|
-
def _inline_literal_text(value: FormattedString.Value) ->
|
|
624
|
+
def _inline_literal_text(value: FormattedString.Value) -> str | None:
|
|
625
625
|
"""The text a constant placeholder prints as, where its source spells exactly that text."""
|
|
626
626
|
if value.conversion is not None or value.format is not None:
|
|
627
627
|
return None
|
|
@@ -11,7 +11,7 @@ See: https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
from itertools import islice
|
|
14
|
-
from typing import Any, Callable, List,
|
|
14
|
+
from typing import Any, Callable, List, Set
|
|
15
15
|
|
|
16
16
|
from rewrite import Cursor, ExecutionContext, Recipe, Tree, TreeVisitor
|
|
17
17
|
from rewrite.category import CategoryDescriptor
|
|
@@ -70,7 +70,7 @@ class _Identifiers(PythonVisitor[Set[str]]):
|
|
|
70
70
|
super().__init__()
|
|
71
71
|
self._skip = skip
|
|
72
72
|
|
|
73
|
-
def visit(self, tree:
|
|
73
|
+
def visit(self, tree: Tree | None, p: Set[str], parent: Cursor | None = None) -> Any:
|
|
74
74
|
if isinstance(tree, J) and tree.id in self._skip:
|
|
75
75
|
return tree
|
|
76
76
|
return super().visit(tree, p, parent)
|
|
@@ -171,7 +171,7 @@ def _without(
|
|
|
171
171
|
padded: List[JRightPadded[Statement]],
|
|
172
172
|
removable: Callable[[Statement], bool],
|
|
173
173
|
keep_one: bool,
|
|
174
|
-
) ->
|
|
174
|
+
) -> List[JRightPadded[Statement]] | None:
|
|
175
175
|
"""The statements that are not ``removable``, or None if that is all of them already.
|
|
176
176
|
|
|
177
177
|
With ``keep_one`` the last statement survives when every one is removable,
|
|
@@ -293,7 +293,7 @@ def _contains_yield(tree: J) -> bool:
|
|
|
293
293
|
return bool(found)
|
|
294
294
|
|
|
295
295
|
|
|
296
|
-
def _enclosing_function(cursor: Cursor) ->
|
|
296
|
+
def _enclosing_function(cursor: Cursor) -> MethodDeclaration | None:
|
|
297
297
|
for value in islice(cursor.get_path(), 1, None):
|
|
298
298
|
if isinstance(value, MethodDeclaration):
|
|
299
299
|
return value
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
"""Replace ``zip(d.keys(), d.values())`` with ``d.items()``."""
|
|
15
15
|
|
|
16
|
-
from typing import Any, List
|
|
16
|
+
from typing import Any, List
|
|
17
17
|
|
|
18
18
|
from rewrite import Cursor, ExecutionContext, Preconditions, Recipe, TreeVisitor
|
|
19
19
|
from rewrite.category import CategoryDescriptor
|
|
@@ -45,7 +45,7 @@ _ZIP_PATTERN = "zip <constructor>(..)"
|
|
|
45
45
|
_ZIP = MethodMatcher.create(_ZIP_PATTERN)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
def _no_arg_call_receiver(node: Expression, method_name: str) ->
|
|
48
|
+
def _no_arg_call_receiver(node: Expression, method_name: str) -> Expression | None:
|
|
49
49
|
"""The receiver of ``receiver.<method_name>()``, or None for any other node."""
|
|
50
50
|
if not isinstance(node, MethodInvocation) or node.name.simple_name != method_name:
|
|
51
51
|
return None
|
|
@@ -4,7 +4,7 @@ Python indentation lives in the ``Space`` before each token, so moving a block
|
|
|
4
4
|
to a shallower nesting level means rewriting every line it spans.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import TypeVar, cast
|
|
8
8
|
|
|
9
9
|
from rewrite.java.markers import TrailingComma
|
|
10
10
|
from rewrite.java.support_types import Space
|
|
@@ -28,7 +28,7 @@ def inherited_prefix(dropped: Space, body: Space) -> Space:
|
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def line_indent(space: Space) ->
|
|
31
|
+
def line_indent(space: Space) -> str | None:
|
|
32
32
|
"""Indentation of the line the token following *space* starts on, or
|
|
33
33
|
``None`` when that token shares a line with what precedes it.
|
|
34
34
|
|
|
@@ -54,7 +54,7 @@ class _Reindent(PythonVisitor[None]):
|
|
|
54
54
|
self._old_base = old_base
|
|
55
55
|
self._new_base = new_base
|
|
56
56
|
|
|
57
|
-
def visit_space(self, space:
|
|
57
|
+
def visit_space(self, space: Space | None, p: None) -> Space:
|
|
58
58
|
if space is None:
|
|
59
59
|
return Space.EMPTY
|
|
60
60
|
whitespace = _rebase(space.whitespace, self._old_base, self._new_base)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Semantic equality of LST nodes, for recipes that keep one of two equal subtrees."""
|
|
2
2
|
|
|
3
|
-
from typing import List
|
|
3
|
+
from typing import List
|
|
4
4
|
|
|
5
5
|
from rewrite.java.support_types import J, Space
|
|
6
6
|
from rewrite.python.template.comparator import PythonComparatorVisitor
|
|
@@ -9,7 +9,7 @@ from rewrite.visitor import Cursor
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class _CommentTexts(PythonVisitor[List[str]]):
|
|
12
|
-
def visit_space(self, space:
|
|
12
|
+
def visit_space(self, space: Space | None, p: List[str]) -> Space:
|
|
13
13
|
if space is not None:
|
|
14
14
|
p.extend(comment.text for comment in space.comments)
|
|
15
15
|
return super().visit_space(space, p)
|
|
@@ -25,7 +25,7 @@ class SemanticallyEqual:
|
|
|
25
25
|
"""Compare two LST nodes for structural equality."""
|
|
26
26
|
|
|
27
27
|
@staticmethod
|
|
28
|
-
def are_equal(a:
|
|
28
|
+
def are_equal(a: J | None, b: J | None) -> bool:
|
|
29
29
|
"""Whether *a* and *b* are the same code carrying the same comments.
|
|
30
30
|
|
|
31
31
|
Whitespace is ignored. Comments must match, so a recipe dropping either copy loses none.
|
|
@@ -8,7 +8,7 @@ between its neighbours.
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
from itertools import islice
|
|
11
|
-
from typing import Any, List,
|
|
11
|
+
from typing import Any, List, Tuple
|
|
12
12
|
|
|
13
13
|
from rewrite import Cursor
|
|
14
14
|
from rewrite.markers import Marker
|
|
@@ -20,7 +20,7 @@ from rewrite.python.visitor import PythonVisitor
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class _CommentFinder(PythonVisitor[List[Space]]):
|
|
23
|
-
def visit_space(self, space:
|
|
23
|
+
def visit_space(self, space: Space | None, p: List[Space]) -> Any:
|
|
24
24
|
if space is not None and space.comments:
|
|
25
25
|
p.append(space)
|
|
26
26
|
return space
|
|
@@ -39,7 +39,7 @@ def has_comments(tree: J) -> bool:
|
|
|
39
39
|
return bool(found)
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
def split_line(space: Space) ->
|
|
42
|
+
def split_line(space: Space) -> Tuple[Space, Space] | None:
|
|
43
43
|
"""Split ``space`` at its first newline, or return None if it has no newline.
|
|
44
44
|
|
|
45
45
|
The head is the trivia that still belongs to the preceding line -- most
|
|
@@ -95,7 +95,7 @@ def opens_with_trailing_comment(space: Space) -> bool:
|
|
|
95
95
|
return bool((split[0] if split else space).comments)
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
def space_after_block(cursor: Cursor) ->
|
|
98
|
+
def space_after_block(cursor: Cursor) -> Space | None:
|
|
99
99
|
"""The trivia the printer emits after the block at ``cursor``.
|
|
100
100
|
|
|
101
101
|
A block's last statement keeps its trailing comment outside the block --
|
|
@@ -140,7 +140,7 @@ def splice_out(
|
|
|
140
140
|
survivor; the removed statement's go with it.
|
|
141
141
|
"""
|
|
142
142
|
result = []
|
|
143
|
-
pending:
|
|
143
|
+
pending: Tuple[Space, Space] | None = None
|
|
144
144
|
for i, padded in enumerate(padded_statements):
|
|
145
145
|
if i in to_remove:
|
|
146
146
|
if pending is None:
|
|
@@ -9,7 +9,7 @@ complexity and making it obvious that the code always runs.
|
|
|
9
9
|
See: https://rules.sonarsource.com/python/RSPEC-S3923/
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
from typing import Any, List
|
|
12
|
+
from typing import Any, List
|
|
13
13
|
|
|
14
14
|
from rewrite import ExecutionContext, Recipe, TreeVisitor
|
|
15
15
|
from rewrite.category import CategoryDescriptor
|
|
@@ -170,7 +170,7 @@ class AllBranchesIdentical(Recipe):
|
|
|
170
170
|
return Visitor()
|
|
171
171
|
|
|
172
172
|
|
|
173
|
-
def _replace_identical_ifs_padded(padded_stmts) ->
|
|
173
|
+
def _replace_identical_ifs_padded(padded_stmts) -> list | None:
|
|
174
174
|
"""Replace if/elif/else with identical branches with just the body.
|
|
175
175
|
|
|
176
176
|
Works on a list of JRightPadded[Statement] and returns a new padded list,
|
|
@@ -8,7 +8,7 @@ was likely meant to be ``0 <= x <= 10``. This is a search recipe: the
|
|
|
8
8
|
intent is ambiguous, so it flags the expression rather than rewriting it.
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
from typing import Any, List
|
|
11
|
+
from typing import Any, List
|
|
12
12
|
|
|
13
13
|
from rewrite import ExecutionContext, Recipe, TreeVisitor
|
|
14
14
|
from rewrite.category import CategoryDescriptor
|
|
@@ -28,7 +28,7 @@ _LESS = (JBinary.Type.LessThan, JBinary.Type.LessThanOrEqual)
|
|
|
28
28
|
_GREATER = (JBinary.Type.GreaterThan, JBinary.Type.GreaterThanOrEqual)
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def _direction(operator: JBinary.Type) ->
|
|
31
|
+
def _direction(operator: JBinary.Type) -> str | None:
|
|
32
32
|
"""Classify an ordering operator as ``"less"``, ``"greater"``, or None."""
|
|
33
33
|
if operator in _LESS:
|
|
34
34
|
return "less"
|
|
@@ -9,7 +9,7 @@ dead branch eliminates confusion and potential maintenance hazards.
|
|
|
9
9
|
See: https://rules.sonarsource.com/python/RSPEC-S1862/
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
from typing import Any, List
|
|
12
|
+
from typing import Any, List
|
|
13
13
|
|
|
14
14
|
from rewrite import ExecutionContext, Recipe, TreeVisitor
|
|
15
15
|
from rewrite.category import CategoryDescriptor
|
|
@@ -183,7 +183,7 @@ def _replace_else(root: If, target: If, new_else) -> If:
|
|
|
183
183
|
return root.replace(_else_part=new_else_part)
|
|
184
184
|
|
|
185
185
|
|
|
186
|
-
def _find_same_node(root: If, target: If) ->
|
|
186
|
+
def _find_same_node(root: If, target: If) -> If | None:
|
|
187
187
|
"""Find the node in the rebuilt chain that corresponds to target."""
|
|
188
188
|
if root.id == target.id:
|
|
189
189
|
return root
|
|
@@ -10,7 +10,7 @@ See: https://rules.sonarsource.com/python/RSPEC-S1656/
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
from itertools import islice
|
|
13
|
-
from typing import Any, List,
|
|
13
|
+
from typing import Any, List, Tuple
|
|
14
14
|
|
|
15
15
|
from rewrite import Cursor, ExecutionContext, Recipe, TreeVisitor
|
|
16
16
|
from rewrite.category import CategoryDescriptor
|
|
@@ -75,7 +75,7 @@ def _in_function_scope(cursor: Cursor) -> bool:
|
|
|
75
75
|
return False
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
def _removable(padded_statements: list, i: int, after_block:
|
|
78
|
+
def _removable(padded_statements: list, i: int, after_block: Space | None) -> bool:
|
|
79
79
|
"""Return True when statement ``i`` can be dropped without disturbing its neighbours.
|
|
80
80
|
|
|
81
81
|
The removal is expressed by splicing line-level trivia, so the statement
|
|
@@ -94,8 +94,8 @@ def _removable(padded_statements: list, i: int, after_block: Optional[Space]) ->
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
def _remove_self_assignments(
|
|
97
|
-
padded_statements: list, end: Space, after_block:
|
|
98
|
-
) ->
|
|
97
|
+
padded_statements: list, end: Space, after_block: Space | None
|
|
98
|
+
) -> Tuple[list, Space] | None:
|
|
99
99
|
"""Return the block's statements and end trivia with self-assignments removed, or None if unchanged.
|
|
100
100
|
|
|
101
101
|
Emptying a block would leave its header without a body, so the last
|