From 9ae698fe30cf3526f0e7ae237b800b3ed19a819f Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 16 May 2025 13:25:28 +0200 Subject: [PATCH] Switch to Rust 2024 edition (#18129) --- .github/workflows/ci.yaml | 4 +- Cargo.toml | 2 +- crates/ruff/src/args.rs | 26 +- crates/ruff/src/cache.rs | 12 +- crates/ruff/src/commands/add_noqa.rs | 2 +- crates/ruff/src/commands/analyze_graph.rs | 4 +- crates/ruff/src/commands/check.rs | 10 +- crates/ruff/src/commands/check_stdin.rs | 4 +- crates/ruff/src/commands/config.rs | 2 +- crates/ruff/src/commands/format.rs | 67 +- crates/ruff/src/commands/format_stdin.rs | 8 +- crates/ruff/src/commands/show_files.rs | 2 +- crates/ruff/src/commands/show_settings.rs | 4 +- crates/ruff/src/diagnostics.rs | 6 +- crates/ruff/src/lib.rs | 8 +- crates/ruff/src/main.rs | 2 +- crates/ruff/src/printer.rs | 28 +- crates/ruff/src/resolve.rs | 6 +- crates/ruff/tests/lint.rs | 64 +- .../src/renderer/display_list.rs | 9 +- .../tests/fixtures/main.rs | 2 +- crates/ruff_benchmark/benches/formatter.rs | 8 +- crates/ruff_benchmark/benches/lexer.rs | 6 +- crates/ruff_benchmark/benches/linter.rs | 12 +- crates/ruff_benchmark/benches/parser.rs | 6 +- crates/ruff_benchmark/benches/ty.rs | 4 +- crates/ruff_cache/src/cache_key.rs | 4 +- crates/ruff_db/src/diagnostic/mod.rs | 2 +- crates/ruff_db/src/diagnostic/render.rs | 10 +- crates/ruff_db/src/files.rs | 4 +- crates/ruff_db/src/files/file_root.rs | 2 +- crates/ruff_db/src/files/path.rs | 4 +- crates/ruff_db/src/parsed.rs | 6 +- crates/ruff_db/src/source.rs | 10 +- crates/ruff_db/src/system.rs | 6 +- crates/ruff_db/src/system/memory_fs.rs | 8 +- crates/ruff_db/src/system/os.rs | 10 +- crates/ruff_db/src/system/test.rs | 8 +- crates/ruff_db/src/testing.rs | 2 +- crates/ruff_db/src/vendored.rs | 10 +- crates/ruff_dev/src/format_dev.rs | 12 +- crates/ruff_dev/src/generate_cli_help.rs | 6 +- crates/ruff_dev/src/generate_json_schema.rs | 6 +- crates/ruff_dev/src/generate_options.rs | 4 +- crates/ruff_dev/src/generate_rules_table.rs | 16 +- .../ruff_dev/src/generate_ty_cli_reference.rs | 38 +- crates/ruff_dev/src/generate_ty_options.rs | 4 +- crates/ruff_dev/src/generate_ty_rules.rs | 6 +- crates/ruff_dev/src/generate_ty_schema.rs | 6 +- crates/ruff_dev/src/print_ast.rs | 2 +- crates/ruff_dev/src/print_cst.rs | 2 +- crates/ruff_formatter/src/arguments.rs | 6 +- crates/ruff_formatter/src/buffer.rs | 2 +- crates/ruff_formatter/src/builders.rs | 13 +- crates/ruff_formatter/src/diagnostics.rs | 61 +- crates/ruff_formatter/src/format_element.rs | 2 +- .../src/format_element/document.rs | 6 +- .../ruff_formatter/src/format_element/tag.rs | 5 +- crates/ruff_formatter/src/lib.rs | 4 +- crates/ruff_formatter/src/macros.rs | 62 +- crates/ruff_formatter/src/prelude.rs | 4 +- .../ruff_formatter/src/printer/call_stack.rs | 2 +- .../src/printer/line_suffixes.rs | 2 +- crates/ruff_formatter/src/printer/mod.rs | 34 +- crates/ruff_formatter/src/printer/queue.rs | 2 +- crates/ruff_formatter/src/source_code.rs | 5 +- crates/ruff_graph/src/collector.rs | 2 +- crates/ruff_graph/src/db.rs | 4 +- crates/ruff_graph/src/lib.rs | 2 +- crates/ruff_graph/src/resolver.rs | 2 +- crates/ruff_index/src/slice.rs | 2 +- crates/ruff_index/src/vec.rs | 4 +- .../src/checkers/ast/analyze/expression.rs | 2 +- .../src/checkers/ast/annotation.rs | 4 +- crates/ruff_linter/src/checkers/ast/mod.rs | 16 +- crates/ruff_linter/src/checkers/filesystem.rs | 2 +- crates/ruff_linter/src/checkers/imports.rs | 2 +- .../ruff_linter/src/checkers/logical_lines.rs | 11 +- crates/ruff_linter/src/checkers/noqa.rs | 2 +- .../src/checkers/physical_lines.rs | 4 +- crates/ruff_linter/src/checkers/tokens.rs | 2 +- crates/ruff_linter/src/cst/helpers.rs | 4 +- crates/ruff_linter/src/cst/matchers.rs | 2 +- crates/ruff_linter/src/directives.rs | 6 +- crates/ruff_linter/src/doc_lines.rs | 2 +- crates/ruff_linter/src/docstrings/sections.rs | 3 +- crates/ruff_linter/src/fix/codemods.rs | 8 +- crates/ruff_linter/src/fix/edits.rs | 10 +- crates/ruff_linter/src/fix/mod.rs | 6 +- crates/ruff_linter/src/importer/insertion.rs | 4 +- crates/ruff_linter/src/importer/mod.rs | 2 +- crates/ruff_linter/src/lib.rs | 2 +- crates/ruff_linter/src/line_width.rs | 2 +- crates/ruff_linter/src/linter.rs | 22 +- crates/ruff_linter/src/message/azure.rs | 2 +- crates/ruff_linter/src/message/github.rs | 6 +- crates/ruff_linter/src/message/gitlab.rs | 4 +- crates/ruff_linter/src/message/grouped.rs | 4 +- crates/ruff_linter/src/message/json.rs | 4 +- crates/ruff_linter/src/message/junit.rs | 4 +- crates/ruff_linter/src/message/mod.rs | 6 +- crates/ruff_linter/src/message/pylint.rs | 2 +- crates/ruff_linter/src/message/rdjson.rs | 4 +- crates/ruff_linter/src/message/sarif.rs | 4 +- crates/ruff_linter/src/message/text.rs | 4 +- crates/ruff_linter/src/noqa.rs | 26 +- crates/ruff_linter/src/pyproject_toml.rs | 2 +- crates/ruff_linter/src/renamer.rs | 14 +- crates/ruff_linter/src/rule_selector.rs | 14 +- .../airflow/rules/dag_schedule_argument.rs | 2 +- .../airflow/rules/moved_to_provider_in_3.rs | 1106 ++++++++++------- .../src/rules/airflow/rules/removal_in_3.rs | 285 +++-- .../suggested_to_move_to_provider_in_3.rs | 200 +-- .../airflow/rules/suggested_to_update_3_0.rs | 35 +- .../rules/airflow/rules/task_variable_name.rs | 2 +- .../eradicate/rules/commented_out_code.rs | 6 +- .../rules/fastapi_non_annotated_dependency.rs | 2 +- .../rules/fastapi_redundant_response_model.rs | 4 +- .../rules/fastapi_unused_path_parameter.rs | 6 +- .../src/rules/fastapi/rules/mod.rs | 2 +- .../src/rules/flake8_2020/rules/compare.rs | 32 +- .../flake8_2020/rules/name_or_attribute.rs | 2 +- .../src/rules/flake8_2020/rules/subscript.rs | 2 +- .../src/rules/flake8_annotations/helpers.rs | 2 +- .../flake8_annotations/rules/definition.rs | 4 +- .../flake8_async/rules/async_busy_wait.rs | 2 +- .../rules/async_function_with_timeout.rs | 2 +- .../flake8_async/rules/async_zero_sleep.rs | 2 +- .../flake8_async/rules/blocking_http_call.rs | 2 +- .../flake8_async/rules/blocking_open_call.rs | 4 +- .../rules/blocking_process_invocation.rs | 18 +- .../flake8_async/rules/blocking_sleep.rs | 2 +- .../rules/cancel_scope_no_checkpoint.rs | 8 +- .../rules/long_sleep_not_forever.rs | 2 +- .../src/rules/flake8_async/rules/sync_call.rs | 2 +- .../src/rules/flake8_bandit/mod.rs | 2 +- .../rules/flake8_bandit/rules/assert_used.rs | 2 +- .../rules/bad_file_permissions.rs | 2 +- .../rules/flake8_bandit/rules/django_extra.rs | 2 +- .../flake8_bandit/rules/django_raw_sql.rs | 2 +- .../rules/flake8_bandit/rules/exec_used.rs | 2 +- .../flake8_bandit/rules/flask_debug_true.rs | 2 +- .../rules/hardcoded_bind_all_interfaces.rs | 2 +- .../rules/hardcoded_password_default.rs | 2 +- .../rules/hardcoded_password_func_arg.rs | 2 +- .../rules/hardcoded_password_string.rs | 2 +- .../rules/hardcoded_sql_expression.rs | 4 +- .../rules/hardcoded_tmp_directory.rs | 2 +- .../rules/hashlib_insecure_hash_functions.rs | 2 +- .../rules/jinja2_autoescape_false.rs | 2 +- .../rules/logging_config_insecure_listen.rs | 2 +- .../flake8_bandit/rules/mako_templates.rs | 2 +- .../flake8_bandit/rules/paramiko_calls.rs | 2 +- .../rules/request_with_no_cert_validation.rs | 16 +- .../rules/request_without_timeout.rs | 27 +- .../flake8_bandit/rules/shell_injection.rs | 2 +- .../rules/snmp_insecure_version.rs | 2 +- .../rules/snmp_weak_cryptography.rs | 2 +- .../rules/ssh_no_host_key_verification.rs | 2 +- .../rules/ssl_insecure_version.rs | 2 +- .../rules/ssl_with_bad_defaults.rs | 2 +- .../rules/ssl_with_no_version.rs | 2 +- .../rules/suspicious_function_call.rs | 101 +- .../flake8_bandit/rules/suspicious_imports.rs | 2 +- .../rules/tarfile_unsafe_members.rs | 2 +- .../rules/try_except_continue.rs | 2 +- .../flake8_bandit/rules/try_except_pass.rs | 2 +- .../flake8_bandit/rules/unsafe_markup_use.rs | 2 +- .../flake8_bandit/rules/unsafe_yaml_load.rs | 2 +- .../rules/weak_cryptographic_key.rs | 67 +- .../flake8_blind_except/rules/blind_except.rs | 6 +- .../src/rules/flake8_boolean_trap/mod.rs | 2 +- ...olean_default_value_positional_argument.rs | 2 +- .../rules/boolean_positional_value_in_call.rs | 2 +- .../boolean_type_hint_positional_argument.rs | 4 +- .../rules/abstract_base_class.rs | 4 +- .../flake8_bugbear/rules/assert_false.rs | 2 +- .../rules/assert_raises_exception.rs | 2 +- .../rules/assignment_to_os_environ.rs | 2 +- .../rules/batched_without_explicit_strict.rs | 2 +- .../rules/cached_instance_method.rs | 2 +- .../rules/class_as_data_structure.rs | 2 +- .../rules/duplicate_exceptions.rs | 2 +- .../flake8_bugbear/rules/duplicate_value.rs | 4 +- .../rules/except_with_empty_tuple.rs | 2 +- .../except_with_non_exception_classes.rs | 2 +- .../rules/f_string_docstring.rs | 2 +- .../function_call_in_argument_default.rs | 8 +- .../rules/function_uses_loop_variable.rs | 2 +- .../rules/getattr_with_constant.rs | 2 +- .../rules/jump_statement_in_finally.rs | 2 +- .../rules/loop_iterator_mutation.rs | 4 +- .../rules/loop_variable_overrides_iterator.rs | 2 +- .../rules/mutable_argument_default.rs | 6 +- .../rules/mutable_contextvar_default.rs | 4 +- .../rules/no_explicit_stacklevel.rs | 2 +- .../flake8_bugbear/rules/raise_literal.rs | 2 +- .../rules/raise_without_from_inside_except.rs | 2 +- .../rules/re_sub_positional_args.rs | 2 +- .../redundant_tuple_in_exception_handler.rs | 2 +- .../rules/return_in_generator.rs | 2 +- .../rules/reuse_of_groupby_generator.rs | 2 +- .../rules/setattr_with_constant.rs | 2 +- .../star_arg_unpacking_after_keyword_arg.rs | 2 +- .../rules/static_key_dict_comprehension.rs | 2 +- .../rules/strip_with_multi_characters.rs | 2 +- .../rules/unary_prefix_increment_decrement.rs | 2 +- .../rules/unintentional_type_annotation.rs | 2 +- .../rules/unreliable_callable_check.rs | 2 +- .../rules/unused_loop_control_variable.rs | 2 +- .../rules/useless_comparison.rs | 2 +- .../rules/useless_contextlib_suppress.rs | 2 +- .../rules/useless_expression.rs | 4 +- .../rules/zip_without_explicit_strict.rs | 2 +- .../rules/builtin_argument_shadowing.rs | 2 +- .../rules/builtin_attribute_shadowing.rs | 2 +- .../rules/builtin_import_shadowing.rs | 2 +- .../builtin_lambda_argument_shadowing.rs | 2 +- .../rules/builtin_variable_shadowing.rs | 2 +- .../rules/stdlib_module_shadowing.rs | 2 +- .../flake8_commas/rules/trailing_commas.rs | 2 +- .../src/rules/flake8_comprehensions/fixes.rs | 14 +- .../src/rules/flake8_comprehensions/mod.rs | 2 +- .../rules/unnecessary_call_around_sorted.rs | 2 +- .../rules/unnecessary_collection_call.rs | 2 +- .../rules/unnecessary_comprehension.rs | 26 +- .../unnecessary_comprehension_in_call.rs | 2 +- ...cessary_dict_comprehension_for_iterable.rs | 2 +- .../unnecessary_double_cast_or_process.rs | 2 +- .../rules/unnecessary_generator_dict.rs | 2 +- .../rules/unnecessary_generator_list.rs | 4 +- .../rules/unnecessary_generator_set.rs | 4 +- .../rules/unnecessary_list_call.rs | 2 +- .../unnecessary_list_comprehension_dict.rs | 2 +- .../unnecessary_list_comprehension_set.rs | 2 +- .../rules/unnecessary_literal_dict.rs | 2 +- .../rules/unnecessary_literal_set.rs | 2 +- .../unnecessary_literal_within_dict_call.rs | 2 +- .../unnecessary_literal_within_list_call.rs | 2 +- .../unnecessary_literal_within_tuple_call.rs | 2 +- .../rules/unnecessary_map.rs | 4 +- .../rules/unnecessary_subscript_reversal.rs | 2 +- .../rules/missing_copyright_notice.rs | 4 +- .../rules/call_date_fromtimestamp.rs | 2 +- .../flake8_datetimez/rules/call_date_today.rs | 2 +- .../rules/call_datetime_fromtimestamp.rs | 2 +- .../rules/call_datetime_now_without_tzinfo.rs | 2 +- .../call_datetime_strptime_without_zone.rs | 2 +- .../rules/call_datetime_today.rs | 2 +- .../rules/call_datetime_utcfromtimestamp.rs | 2 +- .../rules/call_datetime_utcnow.rs | 2 +- .../rules/call_datetime_without_tzinfo.rs | 2 +- .../rules/datetime_min_max.rs | 2 +- .../rules/flake8_debugger/rules/debugger.rs | 2 +- .../rules/all_with_model_form.rs | 2 +- .../rules/exclude_with_model_form.rs | 2 +- .../src/rules/flake8_django/rules/helpers.rs | 2 +- .../rules/locals_in_render_function.rs | 2 +- .../rules/model_without_dunder_str.rs | 4 +- .../rules/non_leading_receiver_decorator.rs | 2 +- .../rules/nullable_model_string_field.rs | 2 +- .../rules/unordered_body_content_in_model.rs | 6 +- .../rules/string_in_exception.rs | 4 +- .../src/rules/flake8_executable/rules/mod.rs | 2 +- .../rules/shebang_leading_whitespace.rs | 2 +- .../rules/shebang_missing_executable_file.rs | 2 +- .../rules/shebang_missing_python.rs | 2 +- .../rules/shebang_not_executable.rs | 2 +- .../rules/shebang_not_first_line.rs | 2 +- .../src/rules/flake8_fixme/rules/todos.rs | 2 +- .../rules/future_required_type_annotation.rs | 2 +- .../future_rewritable_type_annotation.rs | 2 +- .../rules/f_string_in_gettext_func_call.rs | 2 +- .../rules/format_in_gettext_func_call.rs | 2 +- .../rules/printf_in_gettext_func_call.rs | 2 +- .../rules/explicit.rs | 4 +- .../rules/implicit.rs | 4 +- .../rules/flake8_import_conventions/mod.rs | 2 +- .../rules/banned_import_alias.rs | 2 +- .../rules/banned_import_from.rs | 2 +- .../rules/unconventional_import_alias.rs | 2 +- .../rules/direct_logger_instantiation.rs | 2 +- .../rules/exc_info_outside_except_handler.rs | 4 +- .../rules/exception_without_exc_info.rs | 2 +- .../rules/invalid_get_logger_argument.rs | 2 +- .../log_exception_outside_except_handler.rs | 2 +- .../flake8_logging/rules/root_logger_call.rs | 2 +- .../flake8_logging/rules/undocumented_warn.rs | 2 +- .../rules/flake8_logging_format/violations.rs | 2 +- .../rules/implicit_namespace_package.rs | 14 +- .../rules/duplicate_class_field_definition.rs | 2 +- .../rules/multiple_starts_ends_with.rs | 4 +- .../flake8_pie/rules/non_unique_enums.rs | 2 +- .../rules/reimplemented_container_builtin.rs | 2 +- .../rules/unnecessary_dict_kwargs.rs | 4 +- .../rules/unnecessary_placeholder.rs | 2 +- .../rules/unnecessary_range_start.rs | 4 +- .../flake8_pie/rules/unnecessary_spread.rs | 2 +- .../rules/flake8_print/rules/print_call.rs | 2 +- .../flake8_pyi/rules/any_eq_ne_annotation.rs | 2 +- .../rules/bad_generator_return_type.rs | 2 +- .../rules/bad_version_info_comparison.rs | 2 +- .../flake8_pyi/rules/bytestring_usage.rs | 2 +- .../rules/collections_named_tuple.rs | 2 +- .../rules/complex_assignment_in_stub.rs | 2 +- .../rules/complex_if_statement_in_stub.rs | 2 +- .../rules/custom_type_var_for_self.rs | 4 +- .../flake8_pyi/rules/docstring_in_stubs.rs | 2 +- .../rules/duplicate_literal_member.rs | 2 +- .../rules/duplicate_union_member.rs | 2 +- .../rules/ellipsis_in_non_empty_class_body.rs | 2 +- .../flake8_pyi/rules/exit_annotations.rs | 34 +- .../rules/future_annotations_in_stub.rs | 2 +- .../rules/generic_not_last_base_class.rs | 4 +- .../rules/iter_method_return_iterable.rs | 2 +- .../src/rules/flake8_pyi/rules/mod.rs | 2 +- .../rules/no_return_argument_annotation.rs | 2 +- .../flake8_pyi/rules/non_empty_stub_body.rs | 2 +- .../flake8_pyi/rules/non_self_return_type.rs | 8 +- .../rules/numeric_literal_too_long.rs | 2 +- .../flake8_pyi/rules/pass_in_class_body.rs | 2 +- .../rules/pass_statement_stub_body.rs | 2 +- .../rules/pre_pep570_positional_argument.rs | 2 +- .../flake8_pyi/rules/prefix_type_params.rs | 2 +- .../rules/quoted_annotation_in_stub.rs | 2 +- .../rules/redundant_final_literal.rs | 4 +- .../rules/redundant_literal_union.rs | 4 +- .../rules/redundant_none_literal.rs | 5 +- .../rules/redundant_numeric_union.rs | 2 +- .../rules/flake8_pyi/rules/simple_defaults.rs | 10 +- .../rules/str_or_repr_defined_in_stub.rs | 2 +- .../rules/string_or_bytes_too_long.rs | 2 +- .../rules/stub_body_multiple_statements.rs | 4 +- .../flake8_pyi/rules/type_alias_naming.rs | 6 +- .../flake8_pyi/rules/type_comment_in_stub.rs | 2 +- .../unaliased_collections_abc_set_import.rs | 2 +- .../rules/unnecessary_literal_union.rs | 2 +- .../rules/unnecessary_type_union.rs | 2 +- .../flake8_pyi/rules/unrecognized_platform.rs | 2 +- .../rules/unrecognized_version_info.rs | 2 +- .../rules/unsupported_method_call_on_all.rs | 6 +- .../rules/unused_private_type_definition.rs | 8 +- .../flake8_pytest_style/rules/assertion.rs | 6 +- .../rules/flake8_pytest_style/rules/fail.rs | 2 +- .../flake8_pytest_style/rules/fixture.rs | 12 +- .../flake8_pytest_style/rules/imports.rs | 2 +- .../rules/flake8_pytest_style/rules/marks.rs | 4 +- .../flake8_pytest_style/rules/parametrize.rs | 6 +- .../rules/flake8_pytest_style/rules/patch.rs | 2 +- .../rules/flake8_pytest_style/rules/raises.rs | 2 +- .../rules/test_functions.rs | 2 +- .../rules/unittest_assert.rs | 2 +- .../rules/flake8_pytest_style/rules/warns.rs | 2 +- .../rules/avoidable_escaped_quote.rs | 6 +- .../rules/check_string_quotes.rs | 4 +- .../rules/unnecessary_escaped_quote.rs | 4 +- .../unnecessary_paren_on_raise_exception.rs | 2 +- .../src/rules/flake8_return/mod.rs | 2 +- .../src/rules/flake8_return/rules/function.rs | 8 +- .../rules/private_member_access.rs | 2 +- .../src/rules/flake8_simplify/mod.rs | 2 +- .../flake8_simplify/rules/ast_bool_op.rs | 4 +- .../rules/flake8_simplify/rules/ast_expr.rs | 6 +- .../rules/flake8_simplify/rules/ast_ifexp.rs | 2 +- .../flake8_simplify/rules/ast_unary_op.rs | 2 +- .../rules/flake8_simplify/rules/ast_with.rs | 16 +- .../flake8_simplify/rules/collapsible_if.rs | 32 +- .../rules/enumerate_for_loop.rs | 4 +- .../rules/flake8_simplify/rules/fix_with.rs | 6 +- .../if_else_block_instead_of_dict_get.rs | 14 +- .../if_else_block_instead_of_dict_lookup.rs | 2 +- .../rules/if_else_block_instead_of_if_exp.rs | 38 +- .../rules/if_with_same_arms.rs | 6 +- .../flake8_simplify/rules/key_in_dict.rs | 4 +- .../flake8_simplify/rules/needless_bool.rs | 42 +- .../rules/open_file_with_context_handler.rs | 2 +- .../rules/reimplemented_builtin.rs | 36 +- .../rules/return_in_try_except_finally.rs | 2 +- .../rules/split_static_string.rs | 6 +- .../rules/suppressible_exception.rs | 2 +- .../flake8_simplify/rules/yoda_conditions.rs | 4 +- .../rules/zip_dict_keys_and_values.rs | 10 +- .../rules/no_slots_in_namedtuple_subclass.rs | 4 +- .../rules/no_slots_in_str_subclass.rs | 4 +- .../rules/no_slots_in_tuple_subclass.rs | 2 +- .../flake8_tidy_imports/rules/banned_api.rs | 2 +- .../rules/banned_module_level_imports.rs | 2 +- .../rules/relative_imports.rs | 2 +- .../src/rules/flake8_todos/rules/todos.rs | 4 +- .../src/rules/flake8_type_checking/helpers.rs | 6 +- .../rules/empty_type_checking_block.rs | 2 +- .../rules/runtime_cast_value.rs | 2 +- .../runtime_import_in_type_checking_block.rs | 2 +- .../rules/runtime_string_union.rs | 2 +- .../rules/type_alias_quotes.rs | 2 +- .../rules/typing_only_runtime_import.rs | 4 +- .../rules/unused_arguments.rs | 13 +- .../flake8_use_pathlib/rules/glob_rule.rs | 2 +- .../rules/invalid_pathlib_with_suffix.rs | 4 +- .../rules/os_path_getatime.rs | 2 +- .../rules/os_path_getctime.rs | 2 +- .../rules/os_path_getmtime.rs | 2 +- .../rules/os_path_getsize.rs | 2 +- .../flake8_use_pathlib/rules/os_sep_split.rs | 2 +- .../path_constructor_current_directory.rs | 4 +- .../rules/replaceable_by_pathlib.rs | 2 +- .../rules/flake8_use_pathlib/violations.rs | 2 +- .../flynt/rules/static_join_to_fstring.rs | 2 +- crates/ruff_linter/src/rules/isort/block.rs | 2 +- .../ruff_linter/src/rules/isort/categorize.rs | 6 +- crates/ruff_linter/src/rules/isort/helpers.rs | 2 +- crates/ruff_linter/src/rules/isort/mod.rs | 4 +- .../ruff_linter/src/rules/isort/normalize.rs | 2 +- crates/ruff_linter/src/rules/isort/order.rs | 6 +- .../rules/isort/rules/add_required_imports.rs | 4 +- .../src/rules/isort/rules/organize_imports.rs | 6 +- .../ruff_linter/src/rules/isort/settings.rs | 2 +- .../mccabe/rules/function_is_too_complex.rs | 2 +- crates/ruff_linter/src/rules/numpy/helpers.rs | 4 +- .../rules/numpy/rules/deprecated_function.rs | 2 +- .../numpy/rules/deprecated_type_alias.rs | 2 +- .../src/rules/numpy/rules/legacy_random.rs | 2 +- .../numpy/rules/numpy_2_0_deprecation.rs | 38 +- .../pandas_vet/rules/assignment_to_df.rs | 2 +- .../src/rules/pandas_vet/rules/attr.rs | 4 +- .../src/rules/pandas_vet/rules/call.rs | 4 +- .../pandas_vet/rules/inplace_argument.rs | 6 +- .../rules/nunique_constant_series_check.rs | 4 +- .../src/rules/pandas_vet/rules/pd_merge.rs | 2 +- .../src/rules/pandas_vet/rules/read_table.rs | 2 +- .../src/rules/pandas_vet/rules/subscript.rs | 4 +- .../src/rules/pep8_naming/helpers.rs | 2 +- .../rules/camelcase_imported_as_acronym.rs | 2 +- .../rules/camelcase_imported_as_constant.rs | 2 +- .../rules/camelcase_imported_as_lowercase.rs | 2 +- .../constant_imported_as_non_constant.rs | 2 +- .../pep8_naming/rules/dunder_function_name.rs | 2 +- .../rules/error_suffix_on_exception_name.rs | 2 +- .../rules/invalid_argument_name.rs | 4 +- .../pep8_naming/rules/invalid_class_name.rs | 2 +- .../rules/invalid_first_argument_name.rs | 4 +- .../rules/invalid_function_name.rs | 4 +- .../pep8_naming/rules/invalid_module_name.rs | 2 +- .../lowercase_imported_as_non_lowercase.rs | 2 +- .../mixed_case_variable_in_class_scope.rs | 2 +- .../mixed_case_variable_in_global_scope.rs | 2 +- .../non_lowercase_variable_in_function.rs | 2 +- crates/ruff_linter/src/rules/perflint/mod.rs | 2 +- .../perflint/rules/incorrect_dict_iterator.rs | 2 +- .../rules/manual_dict_comprehension.rs | 32 +- .../rules/manual_list_comprehension.rs | 20 +- .../rules/perflint/rules/manual_list_copy.rs | 2 +- .../perflint/rules/try_except_in_loop.rs | 4 +- .../perflint/rules/unnecessary_list_cast.rs | 4 +- .../ruff_linter/src/rules/pycodestyle/mod.rs | 4 +- .../src/rules/pycodestyle/overlong.rs | 2 +- .../pycodestyle/rules/ambiguous_class_name.rs | 2 +- .../rules/ambiguous_function_name.rs | 2 +- .../rules/ambiguous_variable_name.rs | 2 +- .../rules/pycodestyle/rules/bare_except.rs | 2 +- .../rules/pycodestyle/rules/blank_lines.rs | 4 +- .../pycodestyle/rules/compound_statements.rs | 2 +- .../pycodestyle/rules/doc_line_too_long.rs | 2 +- .../src/rules/pycodestyle/rules/errors.rs | 2 +- .../rules/invalid_escape_sequence.rs | 4 +- .../pycodestyle/rules/lambda_assignment.rs | 2 +- .../rules/pycodestyle/rules/line_too_long.rs | 2 +- .../pycodestyle/rules/literal_comparisons.rs | 2 +- .../logical_lines/extraneous_whitespace.rs | 2 +- .../rules/logical_lines/indentation.rs | 2 +- .../rules/logical_lines/missing_whitespace.rs | 2 +- .../missing_whitespace_after_keyword.rs | 2 +- .../missing_whitespace_around_operator.rs | 2 +- .../pycodestyle/rules/logical_lines/mod.rs | 2 +- .../logical_lines/redundant_backslash.rs | 4 +- .../logical_lines/space_around_operator.rs | 2 +- .../whitespace_around_keywords.rs | 2 +- ...hitespace_around_named_parameter_equals.rs | 2 +- .../whitespace_before_comment.rs | 4 +- .../whitespace_before_parameters.rs | 2 +- .../rules/missing_newline_at_end_of_file.rs | 2 +- .../rules/mixed_spaces_and_tabs.rs | 2 +- .../rules/module_import_not_at_top_of_file.rs | 2 +- .../rules/multiple_imports_on_one_line.rs | 4 +- .../src/rules/pycodestyle/rules/not_tests.rs | 2 +- .../pycodestyle/rules/tab_indentation.rs | 2 +- .../rules/too_many_newlines_at_end_of_file.rs | 2 +- .../pycodestyle/rules/trailing_whitespace.rs | 4 +- .../pycodestyle/rules/type_comparison.rs | 2 +- .../rules/whitespace_after_decorator.rs | 2 +- .../rules/pydoclint/rules/check_docstring.rs | 32 +- .../src/rules/pydocstyle/helpers.rs | 2 +- .../src/rules/pydocstyle/rules/backslashes.rs | 2 +- .../pydocstyle/rules/blank_after_summary.rs | 2 +- .../rules/blank_before_after_class.rs | 4 +- .../rules/blank_before_after_function.rs | 2 +- .../src/rules/pydocstyle/rules/capitalized.rs | 2 +- .../pydocstyle/rules/ends_with_period.rs | 4 +- .../pydocstyle/rules/ends_with_punctuation.rs | 4 +- .../src/rules/pydocstyle/rules/if_needed.rs | 2 +- .../src/rules/pydocstyle/rules/indent.rs | 2 +- .../rules/multi_line_summary_start.rs | 2 +- .../rules/newline_after_last_paragraph.rs | 2 +- .../rules/pydocstyle/rules/no_signature.rs | 2 +- .../rules/no_surrounding_whitespace.rs | 2 +- .../pydocstyle/rules/non_imperative_mood.rs | 2 +- .../src/rules/pydocstyle/rules/not_empty.rs | 2 +- .../src/rules/pydocstyle/rules/not_missing.rs | 4 +- .../src/rules/pydocstyle/rules/one_liner.rs | 2 +- .../src/rules/pydocstyle/rules/sections.rs | 4 +- .../pydocstyle/rules/starts_with_this.rs | 2 +- .../rules/pydocstyle/rules/triple_quotes.rs | 2 +- .../ruff_linter/src/rules/pyflakes/fixes.rs | 2 +- crates/ruff_linter/src/rules/pyflakes/mod.rs | 4 +- .../src/rules/pyflakes/rules/assert_tuple.rs | 2 +- .../pyflakes/rules/break_outside_loop.rs | 2 +- .../pyflakes/rules/continue_outside_loop.rs | 2 +- .../pyflakes/rules/default_except_not_last.rs | 2 +- .../rules/f_string_missing_placeholders.rs | 4 +- .../rules/forward_annotation_syntax_error.rs | 2 +- .../rules/future_feature_not_defined.rs | 2 +- .../src/rules/pyflakes/rules/if_tuple.rs | 2 +- .../src/rules/pyflakes/rules/imports.rs | 2 +- .../rules/invalid_literal_comparisons.rs | 6 +- .../pyflakes/rules/invalid_print_syntax.rs | 2 +- .../pyflakes/rules/raise_not_implemented.rs | 2 +- .../pyflakes/rules/redefined_while_unused.rs | 2 +- .../src/rules/pyflakes/rules/repeated_keys.rs | 2 +- .../pyflakes/rules/return_outside_function.rs | 2 +- .../pyflakes/rules/starred_expressions.rs | 2 +- .../src/rules/pyflakes/rules/strings.rs | 2 +- .../rules/pyflakes/rules/undefined_export.rs | 2 +- .../rules/pyflakes/rules/undefined_local.rs | 2 +- .../rules/pyflakes/rules/undefined_name.rs | 2 +- .../rules/pyflakes/rules/unused_annotation.rs | 2 +- .../src/rules/pyflakes/rules/unused_import.rs | 18 +- .../rules/pyflakes/rules/unused_variable.rs | 2 +- .../pyflakes/rules/yield_outside_function.rs | 2 +- .../rules/pygrep_hooks/rules/blanket_noqa.rs | 4 +- .../pygrep_hooks/rules/blanket_type_ignore.rs | 4 +- .../pygrep_hooks/rules/deprecated_log_warn.rs | 2 +- .../pygrep_hooks/rules/invalid_mock_access.rs | 2 +- .../src/rules/pygrep_hooks/rules/no_eval.rs | 2 +- .../ruff_linter/src/rules/pylint/helpers.rs | 2 +- crates/ruff_linter/src/rules/pylint/mod.rs | 2 +- .../pylint/rules/assert_on_string_literal.rs | 2 +- .../rules/pylint/rules/await_outside_async.rs | 2 +- .../pylint/rules/bad_dunder_method_name.rs | 2 +- .../src/rules/pylint/rules/bad_open_mode.rs | 2 +- .../pylint/rules/bad_staticmethod_argument.rs | 4 +- .../rules/pylint/rules/bad_str_strip_call.rs | 4 +- .../rules/bad_string_format_character.rs | 2 +- .../pylint/rules/bad_string_format_type.rs | 2 +- .../pylint/rules/bidirectional_unicode.rs | 2 +- .../rules/pylint/rules/binary_op_exception.rs | 2 +- .../rules/boolean_chained_comparison.rs | 4 +- .../rules/pylint/rules/collapsible_else_if.rs | 4 +- .../pylint/rules/compare_to_empty_string.rs | 2 +- .../pylint/rules/comparison_of_constant.rs | 2 +- .../pylint/rules/comparison_with_itself.rs | 2 +- .../rules/pylint/rules/continue_in_finally.rs | 2 +- .../pylint/rules/dict_index_missing_items.rs | 7 +- .../pylint/rules/dict_iter_missing_items.rs | 2 +- .../src/rules/pylint/rules/duplicate_bases.rs | 4 +- .../src/rules/pylint/rules/empty_comment.rs | 4 +- .../src/rules/pylint/rules/eq_without_hash.rs | 4 +- .../pylint/rules/global_at_module_level.rs | 2 +- .../rules/pylint/rules/global_statement.rs | 2 +- .../rules/global_variable_not_assigned.rs | 2 +- .../src/rules/pylint/rules/if_stmt_min_max.rs | 14 +- .../pylint/rules/import_outside_top_level.rs | 2 +- .../rules/pylint/rules/import_private_name.rs | 2 +- .../src/rules/pylint/rules/import_self.rs | 2 +- .../rules/pylint/rules/invalid_all_format.rs | 2 +- .../rules/pylint/rules/invalid_all_object.rs | 2 +- .../rules/pylint/rules/invalid_bool_return.rs | 2 +- .../pylint/rules/invalid_bytes_return.rs | 2 +- .../pylint/rules/invalid_envvar_default.rs | 4 +- .../pylint/rules/invalid_envvar_value.rs | 4 +- .../rules/pylint/rules/invalid_hash_return.rs | 2 +- .../pylint/rules/invalid_index_return.rs | 2 +- .../pylint/rules/invalid_length_return.rs | 2 +- .../rules/pylint/rules/invalid_str_return.rs | 2 +- .../pylint/rules/invalid_string_characters.rs | 2 +- .../rules/pylint/rules/iteration_over_set.rs | 4 +- .../src/rules/pylint/rules/len_test.rs | 2 +- .../rules/pylint/rules/literal_membership.rs | 2 +- .../rules/load_before_global_declaration.rs | 2 +- .../src/rules/pylint/rules/logging.rs | 2 +- .../pylint/rules/magic_value_comparison.rs | 2 +- .../rules/pylint/rules/manual_import_from.rs | 2 +- .../pylint/rules/misplaced_bare_raise.rs | 2 +- .../pylint/rules/modified_iterating_set.rs | 2 +- .../rules/named_expr_without_context.rs | 2 +- .../src/rules/pylint/rules/nan_comparison.rs | 2 +- .../src/rules/pylint/rules/nested_min_max.rs | 2 +- .../rules/pylint/rules/no_method_decorator.rs | 2 +- .../src/rules/pylint/rules/no_self_use.rs | 4 +- .../pylint/rules/non_ascii_module_import.rs | 2 +- .../src/rules/pylint/rules/non_ascii_name.rs | 2 +- .../pylint/rules/non_augmented_assignment.rs | 2 +- .../rules/pylint/rules/non_slot_assignment.rs | 2 +- .../rules/pylint/rules/nonlocal_and_global.rs | 2 +- .../pylint/rules/nonlocal_without_binding.rs | 2 +- .../pylint/rules/potential_index_error.rs | 2 +- .../pylint/rules/property_with_parameters.rs | 4 +- .../pylint/rules/redeclared_assigned_name.rs | 2 +- .../rules/redefined_argument_from_local.rs | 2 +- .../rules/pylint/rules/redefined_loop_name.rs | 4 +- .../rules/redefined_slots_in_subclass.rs | 4 +- .../rules/repeated_equality_comparison.rs | 8 +- .../pylint/rules/repeated_isinstance_calls.rs | 2 +- .../pylint/rules/repeated_keyword_argument.rs | 2 +- .../src/rules/pylint/rules/return_in_init.rs | 2 +- .../pylint/rules/self_assigning_variable.rs | 2 +- .../pylint/rules/self_or_cls_assignment.rs | 4 +- .../pylint/rules/shallow_copy_environ.rs | 2 +- .../rules/pylint/rules/single_string_slots.rs | 2 +- .../pylint/rules/singledispatch_method.rs | 4 +- .../rules/singledispatchmethod_function.rs | 4 +- .../rules/subprocess_popen_preexec_fn.rs | 2 +- .../rules/subprocess_run_without_check.rs | 2 +- .../pylint/rules/super_without_brackets.rs | 4 +- .../src/rules/pylint/rules/sys_exit_alias.rs | 2 +- .../rules/pylint/rules/too_many_arguments.rs | 2 +- .../rules/too_many_boolean_expressions.rs | 2 +- .../rules/pylint/rules/too_many_branches.rs | 2 +- .../src/rules/pylint/rules/too_many_locals.rs | 2 +- .../pylint/rules/too_many_nested_blocks.rs | 2 +- .../rules/too_many_positional_arguments.rs | 2 +- .../pylint/rules/too_many_public_methods.rs | 2 +- .../rules/too_many_return_statements.rs | 2 +- .../rules/pylint/rules/too_many_statements.rs | 2 +- .../src/rules/pylint/rules/type_bivariance.rs | 2 +- .../rules/type_name_incorrect_variance.rs | 6 +- .../pylint/rules/type_param_name_mismatch.rs | 2 +- .../unexpected_special_method_signature.rs | 2 +- .../rules/unnecessary_dict_index_lookup.rs | 2 +- .../rules/unnecessary_direct_lambda_call.rs | 2 +- .../pylint/rules/unnecessary_dunder_call.rs | 2 +- .../rules/pylint/rules/unnecessary_lambda.rs | 4 +- .../rules/unnecessary_list_index_lookup.rs | 2 +- .../src/rules/pylint/rules/unreachable.rs | 4 +- .../pylint/rules/unspecified_encoding.rs | 15 +- .../pylint/rules/useless_else_on_loop.rs | 4 +- .../rules/useless_exception_statement.rs | 2 +- .../pylint/rules/useless_import_alias.rs | 2 +- .../src/rules/pylint/rules/useless_return.rs | 2 +- .../rules/pylint/rules/useless_with_lock.rs | 2 +- .../rules/yield_from_in_async_function.rs | 2 +- .../src/rules/pylint/rules/yield_in_init.rs | 2 +- ...convert_named_tuple_functional_to_class.rs | 2 +- .../convert_typed_dict_functional_to_class.rs | 2 +- .../pyupgrade/rules/datetime_utc_alias.rs | 2 +- .../rules/deprecated_c_element_tree.rs | 2 +- .../pyupgrade/rules/deprecated_import.rs | 4 +- .../pyupgrade/rules/deprecated_mock_import.rs | 4 +- .../rules/deprecated_unittest_alias.rs | 2 +- .../pyupgrade/rules/extraneous_parentheses.rs | 2 +- .../src/rules/pyupgrade/rules/f_strings.rs | 4 +- .../rules/pyupgrade/rules/format_literals.rs | 6 +- .../rules/lru_cache_with_maxsize_none.rs | 2 +- .../rules/lru_cache_without_parameters.rs | 2 +- .../rules/pyupgrade/rules/native_literals.rs | 2 +- .../pyupgrade/rules/non_pep646_unpack.rs | 2 +- .../src/rules/pyupgrade/rules/open_alias.rs | 2 +- .../rules/pyupgrade/rules/os_error_alias.rs | 2 +- .../pyupgrade/rules/outdated_version_block.rs | 4 +- .../src/rules/pyupgrade/rules/pep695/mod.rs | 7 +- .../rules/pep695/non_pep695_generic_class.rs | 6 +- .../pep695/non_pep695_generic_function.rs | 6 +- .../rules/pep695/non_pep695_type_alias.rs | 16 +- .../rules/pep695/private_type_parameter.rs | 2 +- .../rules/printf_string_formatting.rs | 10 +- .../pyupgrade/rules/quoted_annotation.rs | 2 +- .../pyupgrade/rules/redundant_open_modes.rs | 2 +- .../pyupgrade/rules/replace_stdout_stderr.rs | 4 +- .../rules/pyupgrade/rules/replace_str_enum.rs | 2 +- .../rules/replace_universal_newlines.rs | 4 +- .../rules/super_call_with_parameters.rs | 2 +- .../pyupgrade/rules/timeout_error_alias.rs | 2 +- .../pyupgrade/rules/type_of_primitive.rs | 2 +- .../pyupgrade/rules/typing_text_str_alias.rs | 2 +- .../pyupgrade/rules/unicode_kind_prefix.rs | 2 +- .../rules/unnecessary_builtin_import.rs | 2 +- .../rules/unnecessary_class_parentheses.rs | 2 +- .../rules/unnecessary_coding_comment.rs | 2 +- .../rules/unnecessary_default_type_args.rs | 2 +- .../rules/unnecessary_encode_utf8.rs | 6 +- .../rules/unnecessary_future_import.rs | 2 +- .../pyupgrade/rules/use_pep585_annotation.rs | 2 +- .../pyupgrade/rules/use_pep604_annotation.rs | 4 +- .../pyupgrade/rules/use_pep604_isinstance.rs | 4 +- .../pyupgrade/rules/useless_metaclass_type.rs | 2 +- .../rules/useless_object_inheritance.rs | 4 +- .../pyupgrade/rules/yield_in_for_loop.rs | 2 +- .../src/rules/refurb/rules/bit_count.rs | 2 +- .../refurb/rules/check_and_remove_from_set.rs | 4 +- .../rules/refurb/rules/delete_full_slice.rs | 4 +- .../refurb/rules/for_loop_set_mutations.rs | 2 +- .../src/rules/refurb/rules/for_loop_writes.rs | 2 +- .../refurb/rules/fromisoformat_replace_z.rs | 2 +- .../refurb/rules/fstring_number_format.rs | 2 +- .../refurb/rules/hardcoded_string_charset.rs | 2 +- .../rules/refurb/rules/hashlib_digest_hex.rs | 2 +- .../rules/if_exp_instead_of_or_operator.rs | 6 +- .../src/rules/refurb/rules/if_expr_min_max.rs | 2 +- .../src/rules/refurb/rules/implicit_cwd.rs | 2 +- .../rules/refurb/rules/int_on_sliced_str.rs | 2 +- .../refurb/rules/isinstance_type_none.rs | 2 +- .../rules/refurb/rules/list_reverse_copy.rs | 4 +- .../src/rules/refurb/rules/math_constant.rs | 2 +- .../rules/refurb/rules/metaclass_abcmeta.rs | 2 +- .../rules/refurb/rules/print_empty_string.rs | 2 +- .../src/rules/refurb/rules/read_whole_file.rs | 4 +- .../rules/refurb/rules/readlines_in_for.rs | 2 +- .../rules/refurb/rules/redundant_log_base.rs | 2 +- .../rules/refurb/rules/regex_flag_alias.rs | 2 +- .../refurb/rules/reimplemented_operator.rs | 4 +- .../refurb/rules/reimplemented_starmap.rs | 4 +- .../src/rules/refurb/rules/repeated_append.rs | 10 +- .../src/rules/refurb/rules/repeated_global.rs | 2 +- .../rules/single_item_membership_test.rs | 2 +- .../src/rules/refurb/rules/slice_copy.rs | 2 +- .../rules/slice_to_remove_prefix_or_suffix.rs | 4 +- .../src/rules/refurb/rules/sorted_min_max.rs | 2 +- .../rules/refurb/rules/subclass_builtin.rs | 4 +- .../refurb/rules/type_none_comparison.rs | 2 +- .../refurb/rules/unnecessary_enumerate.rs | 2 +- .../refurb/rules/unnecessary_from_float.rs | 2 +- .../rules/verbose_decimal_constructor.rs | 2 +- .../rules/refurb/rules/write_whole_file.rs | 4 +- crates/ruff_linter/src/rules/ruff/mod.rs | 2 +- .../ruff/rules/ambiguous_unicode_character.rs | 6 +- .../ruff/rules/assert_with_print_message.rs | 2 +- .../rules/ruff/rules/assignment_in_assert.rs | 2 +- .../rules/ruff/rules/asyncio_dangling_task.rs | 4 +- .../ruff/rules/class_with_mixed_type_vars.rs | 6 +- .../rules/collection_literal_concatenation.rs | 2 +- .../src/rules/ruff/rules/dataclass_enum.rs | 4 +- .../ruff/rules/decimal_from_float_literal.rs | 4 +- .../rules/ruff/rules/default_factory_kwarg.rs | 8 +- .../explicit_f_string_type_conversion.rs | 6 +- .../ruff/rules/falsy_dict_get_fallback.rs | 6 +- .../function_call_in_dataclass_default.rs | 6 +- .../src/rules/ruff/rules/helpers.rs | 4 +- .../rules/ruff/rules/if_key_in_dict_del.rs | 2 +- .../rules/implicit_classvar_in_dataclass.rs | 4 +- .../src/rules/ruff/rules/implicit_optional.rs | 2 +- .../rules/ruff/rules/in_empty_collection.rs | 2 +- ...rectly_parenthesized_tuple_in_subscript.rs | 2 +- .../rules/ruff/rules/indented_form_feed.rs | 2 +- ...invalid_assert_message_literal_argument.rs | 2 +- .../invalid_formatter_suppression_comment.rs | 8 +- .../rules/ruff/rules/invalid_index_type.rs | 6 +- .../ruff/rules/invalid_pyproject_toml.rs | 2 +- .../src/rules/ruff/rules/invalid_rule_code.rs | 4 +- .../ruff/rules/map_int_version_parsing.rs | 2 +- .../ruff/rules/missing_fstring_syntax.rs | 4 +- .../rules/ruff/rules/mutable_class_default.rs | 2 +- .../ruff/rules/mutable_dataclass_default.rs | 2 +- .../ruff/rules/mutable_fromkeys_value.rs | 2 +- .../src/rules/ruff/rules/needless_else.rs | 2 +- .../src/rules/ruff/rules/never_union.rs | 4 +- .../ruff/rules/none_not_at_end_of_union.rs | 2 +- .../rules/parenthesize_chained_operators.rs | 2 +- .../src/rules/ruff/rules/post_init_default.rs | 4 +- .../rules/pytest_raises_ambiguous_pattern.rs | 2 +- .../ruff/rules/quadratic_list_summation.rs | 2 +- .../src/rules/ruff/rules/redirected_noqa.rs | 2 +- .../ruff/rules/redundant_bool_literal.rs | 2 +- .../src/rules/ruff/rules/sequence_sorting.rs | 6 +- .../src/rules/ruff/rules/sort_dunder_all.rs | 6 +- .../src/rules/ruff/rules/sort_dunder_slots.rs | 8 +- .../src/rules/ruff/rules/starmap_zip.rs | 4 +- .../rules/static_key_dict_comprehension.rs | 2 +- .../ruff/rules/suppression_comment_visitor.rs | 4 +- .../src/rules/ruff/rules/test_rules.rs | 4 +- .../ruff/rules/unnecessary_cast_to_int.rs | 17 +- ...y_iterable_allocation_for_first_element.rs | 10 +- .../rules/ruff/rules/unnecessary_key_check.rs | 2 +- .../unnecessary_literal_within_deque_call.rs | 2 +- .../ruff/rules/unnecessary_nested_literal.rs | 2 +- .../rules/unnecessary_regular_expression.rs | 2 +- .../src/rules/ruff/rules/unnecessary_round.rs | 6 +- .../src/rules/ruff/rules/unraw_re_pattern.rs | 2 +- .../src/rules/ruff/rules/unsafe_markup_use.rs | 2 +- .../src/rules/ruff/rules/unused_async.rs | 4 +- .../src/rules/ruff/rules/unused_noqa.rs | 2 +- .../ruff/rules/unused_unpacked_variable.rs | 2 +- .../rules/ruff/rules/used_dummy_variable.rs | 2 +- .../src/rules/ruff/rules/useless_if_else.rs | 2 +- .../ruff/rules/zip_instead_of_pairwise.rs | 2 +- .../src/rules/tryceratops/helpers.rs | 2 +- .../rules/error_instead_of_exception.rs | 2 +- .../tryceratops/rules/raise_vanilla_args.rs | 2 +- .../tryceratops/rules/raise_vanilla_class.rs | 4 +- .../tryceratops/rules/raise_within_try.rs | 4 +- .../tryceratops/rules/reraise_no_cause.rs | 2 +- .../tryceratops/rules/try_consider_else.rs | 2 +- .../rules/type_check_without_type_error.rs | 4 +- .../tryceratops/rules/useless_try_except.rs | 2 +- .../tryceratops/rules/verbose_log_message.rs | 2 +- .../rules/tryceratops/rules/verbose_raise.rs | 4 +- .../src/settings/fix_safety_table.rs | 3 +- crates/ruff_linter/src/settings/flags.rs | 6 +- crates/ruff_linter/src/settings/mod.rs | 2 +- crates/ruff_linter/src/settings/types.rs | 8 +- crates/ruff_linter/src/test.rs | 6 +- crates/ruff_macros/src/cache_key.rs | 4 +- crates/ruff_macros/src/config.rs | 15 +- .../ruff_macros/src/derive_message_formats.rs | 2 +- crates/ruff_macros/src/lib.rs | 2 +- crates/ruff_macros/src/map_codes.rs | 6 +- crates/ruff_notebook/src/cell.rs | 2 +- crates/ruff_notebook/src/notebook.rs | 6 +- crates/ruff_python_ast/src/helpers.rs | 2 +- crates/ruff_python_ast/src/identifier.rs | 2 +- crates/ruff_python_ast/src/name.rs | 12 +- crates/ruff_python_ast/src/node.rs | 85 +- crates/ruff_python_ast/src/nodes.rs | 17 +- crates/ruff_python_ast/src/python_version.rs | 6 +- crates/ruff_python_ast/src/relocate.rs | 2 +- crates/ruff_python_ast/src/whitespace.rs | 2 +- .../tests/comparable.rs | 2 +- .../tests/identifier.rs | 2 +- .../tests/source_order.rs | 2 +- .../tests/stmt_if.rs | 2 +- .../tests/visitor.rs | 5 +- crates/ruff_python_codegen/src/generator.rs | 16 +- crates/ruff_python_codegen/src/lib.rs | 2 +- crates/ruff_python_codegen/src/stylist.rs | 8 +- crates/ruff_python_formatter/src/builders.rs | 2 +- crates/ruff_python_formatter/src/cli.rs | 6 +- .../src/comments/format.rs | 11 +- .../ruff_python_formatter/src/comments/mod.rs | 2 +- .../src/comments/placement.rs | 10 +- crates/ruff_python_formatter/src/context.rs | 2 +- crates/ruff_python_formatter/src/db.rs | 2 +- .../src/expression/binary_like.rs | 8 +- .../src/expression/expr_attribute.rs | 10 +- .../src/expression/expr_await.rs | 2 +- .../src/expression/expr_bytes_literal.rs | 4 +- .../src/expression/expr_call.rs | 6 +- .../src/expression/expr_dict.rs | 4 +- .../src/expression/expr_dict_comp.rs | 2 +- .../src/expression/expr_f_string.rs | 4 +- .../src/expression/expr_generator.rs | 4 +- .../src/expression/expr_if.rs | 6 +- .../src/expression/expr_list.rs | 2 +- .../src/expression/expr_list_comp.rs | 4 +- .../src/expression/expr_named.rs | 2 +- .../src/expression/expr_set.rs | 2 +- .../src/expression/expr_set_comp.rs | 4 +- .../src/expression/expr_slice.rs | 4 +- .../src/expression/expr_string_literal.rs | 4 +- .../src/expression/expr_subscript.rs | 6 +- .../src/expression/expr_tuple.rs | 4 +- .../src/expression/expr_unary_op.rs | 2 +- .../src/expression/expr_yield.rs | 2 +- .../src/expression/mod.rs | 12 +- .../src/expression/parentheses.rs | 14 +- crates/ruff_python_formatter/src/lib.rs | 18 +- crates/ruff_python_formatter/src/main.rs | 6 +- .../src/module/mod_module.rs | 2 +- crates/ruff_python_formatter/src/options.rs | 8 +- .../src/other/arguments.rs | 4 +- .../ruff_python_formatter/src/other/commas.rs | 2 +- .../src/other/comprehension.rs | 4 +- .../other/except_handler_except_handler.rs | 4 +- .../src/other/f_string_element.rs | 2 +- .../src/other/match_case.rs | 4 +- .../src/other/parameter_with_default.rs | 34 +- .../src/other/parameters.rs | 28 +- .../src/other/string_literal.rs | 4 +- .../src/other/with_item.rs | 4 +- .../ruff_python_formatter/src/pattern/mod.rs | 4 +- .../src/pattern/pattern_arguments.rs | 2 +- .../src/pattern/pattern_match_mapping.rs | 4 +- .../src/pattern/pattern_match_or.rs | 4 +- .../src/pattern/pattern_match_sequence.rs | 8 +- crates/ruff_python_formatter/src/prelude.rs | 4 +- crates/ruff_python_formatter/src/range.rs | 10 +- .../src/statement/clause.rs | 24 +- .../src/statement/stmt_assign.rs | 15 +- .../src/statement/stmt_aug_assign.rs | 6 +- .../src/statement/stmt_class_def.rs | 4 +- .../src/statement/stmt_delete.rs | 4 +- .../src/statement/stmt_for.rs | 2 +- .../src/statement/stmt_function_def.rs | 2 +- .../src/statement/stmt_if.rs | 2 +- .../src/statement/stmt_import_from.rs | 2 +- .../src/statement/stmt_match.rs | 2 +- .../src/statement/stmt_try.rs | 6 +- .../src/statement/stmt_while.rs | 2 +- .../src/statement/stmt_with.rs | 4 +- .../src/statement/suite.rs | 6 +- .../src/string/docstring.rs | 10 +- .../src/string/implicit.rs | 9 +- .../ruff_python_formatter/src/string/mod.rs | 9 +- .../src/string/normalize.rs | 6 +- crates/ruff_python_formatter/src/verbatim.rs | 8 +- .../ruff_python_formatter/tests/fixtures.rs | 4 +- .../ruff_python_formatter/tests/normalizer.rs | 2 +- crates/ruff_python_index/src/indexer.rs | 2 +- crates/ruff_python_literal/src/escape.rs | 2 +- crates/ruff_python_parser/src/error.rs | 10 +- crates/ruff_python_parser/src/lexer.rs | 25 +- .../src/parser/expression.rs | 4 +- .../ruff_python_parser/src/parser/helpers.rs | 4 +- .../ruff_python_parser/src/parser/pattern.rs | 4 +- .../src/parser/statement.rs | 6 +- crates/ruff_python_parser/src/parser/tests.rs | 2 +- .../ruff_python_parser/src/semantic_errors.rs | 14 +- crates/ruff_python_parser/src/string.rs | 4 +- crates/ruff_python_parser/src/token_source.rs | 2 +- crates/ruff_python_parser/src/typing.rs | 2 +- crates/ruff_python_parser/tests/fixtures.rs | 15 +- crates/ruff_python_resolver/src/lib.rs | 2 +- crates/ruff_python_resolver/src/resolver.rs | 4 +- .../src/analyze/type_inference.rs | 6 +- .../src/analyze/typing.rs | 4 +- crates/ruff_python_semantic/src/binding.rs | 4 +- crates/ruff_python_semantic/src/branches.rs | 2 +- crates/ruff_python_semantic/src/cfg/graph.rs | 4 +- .../ruff_python_semantic/src/cfg/visualize.rs | 2 +- crates/ruff_python_semantic/src/definition.rs | 8 +- crates/ruff_python_semantic/src/globals.rs | 4 +- crates/ruff_python_semantic/src/imports.rs | 2 +- crates/ruff_python_semantic/src/model.rs | 2 +- crates/ruff_python_semantic/src/model/all.rs | 2 +- crates/ruff_python_semantic/src/nodes.rs | 2 +- crates/ruff_python_semantic/src/reference.rs | 2 +- crates/ruff_python_semantic/src/scope.rs | 2 +- crates/ruff_python_stdlib/src/str.rs | 4 +- crates/ruff_python_trivia/src/comments.rs | 2 +- crates/ruff_python_trivia/src/tokenizer.rs | 2 +- .../tests/block_comments.rs | 2 +- .../tests/simple_tokenizer.rs | 4 +- .../tests/whitespace.rs | 2 +- crates/ruff_server/src/edit/range.rs | 4 +- crates/ruff_server/src/edit/text_document.rs | 8 +- crates/ruff_server/src/fix.rs | 4 +- crates/ruff_server/src/format.rs | 4 +- crates/ruff_server/src/lint.rs | 6 +- crates/ruff_server/src/logging.rs | 2 +- crates/ruff_server/src/server.rs | 12 +- crates/ruff_server/src/server/api.rs | 6 +- .../src/server/api/notifications/cancel.rs | 2 +- .../server/api/notifications/did_change.rs | 6 +- .../notifications/did_change_configuration.rs | 2 +- .../api/notifications/did_change_notebook.rs | 6 +- .../notifications/did_change_watched_files.rs | 4 +- .../api/notifications/did_change_workspace.rs | 2 +- .../src/server/api/notifications/did_close.rs | 6 +- .../api/notifications/did_close_notebook.rs | 2 +- .../src/server/api/notifications/did_open.rs | 10 +- .../api/notifications/did_open_notebook.rs | 6 +- .../src/server/api/requests/code_action.rs | 12 +- .../api/requests/code_action_resolve.rs | 6 +- .../src/server/api/requests/diagnostic.rs | 2 +- .../server/api/requests/execute_command.rs | 6 +- .../src/server/api/requests/format.rs | 2 +- .../src/server/api/requests/format_range.rs | 4 +- .../src/server/api/requests/hover.rs | 2 +- crates/ruff_server/src/server/client.rs | 2 +- crates/ruff_server/src/server/connection.rs | 4 +- crates/ruff_server/src/server/schedule.rs | 2 +- .../src/server/schedule/thread/pool.rs | 2 +- crates/ruff_server/src/session/index.rs | 4 +- .../src/session/index/ruff_settings.rs | 4 +- crates/ruff_server/src/session/settings.rs | 8 +- crates/ruff_server/src/workspace.rs | 2 +- crates/ruff_server/tests/notebook.rs | 8 +- crates/ruff_source_file/src/lib.rs | 4 +- crates/ruff_text_size/src/schemars_impls.rs | 10 +- crates/ruff_wasm/src/lib.rs | 10 +- crates/ruff_workspace/src/configuration.rs | 26 +- crates/ruff_workspace/src/options.rs | 10 +- crates/ruff_workspace/src/pyproject.rs | 40 +- crates/ruff_workspace/src/resolver.rs | 14 +- crates/ruff_workspace/src/settings.rs | 2 +- crates/ty/src/lib.rs | 12 +- crates/ty/src/logging.rs | 2 +- crates/ty/src/main.rs | 2 +- crates/ty/tests/file_watching.rs | 118 +- crates/ty_ide/src/db.rs | 2 +- crates/ty_ide/src/find_node.rs | 2 +- crates/ty_ide/src/goto.rs | 6 +- crates/ty_ide/src/hover.rs | 10 +- crates/ty_ide/src/inlay_hints.rs | 2 +- crates/ty_ide/src/lib.rs | 6 +- crates/ty_project/src/db.rs | 6 +- crates/ty_project/src/db/changes.rs | 6 +- crates/ty_project/src/files.rs | 6 +- crates/ty_project/src/lib.rs | 16 +- crates/ty_project/src/metadata.rs | 45 +- crates/ty_project/src/metadata/options.rs | 10 +- crates/ty_project/src/metadata/pyproject.rs | 11 +- crates/ty_project/src/metadata/value.rs | 2 +- crates/ty_project/src/walk.rs | 2 +- crates/ty_project/src/watch.rs | 2 +- .../ty_project/src/watch/project_watcher.rs | 6 +- crates/ty_project/src/watch/watcher.rs | 2 +- crates/ty_project/tests/check.rs | 13 +- crates/ty_python_semantic/src/ast_node_ref.rs | 2 +- crates/ty_python_semantic/src/db.rs | 2 +- crates/ty_python_semantic/src/dunder_all.rs | 8 +- crates/ty_python_semantic/src/lib.rs | 2 +- crates/ty_python_semantic/src/list.rs | 2 +- .../src/module_resolver/mod.rs | 4 +- .../src/module_resolver/path.rs | 24 +- .../src/module_resolver/resolver.rs | 48 +- .../src/module_resolver/typeshed.rs | 4 +- crates/ty_python_semantic/src/program.rs | 2 +- .../ty_python_semantic/src/python_platform.rs | 4 +- .../ty_python_semantic/src/semantic_index.rs | 19 +- .../src/semantic_index/ast_ids.rs | 2 +- .../src/semantic_index/builder.rs | 16 +- .../src/semantic_index/definition.rs | 64 +- .../src/semantic_index/predicate.rs | 2 +- .../src/semantic_index/re_exports.rs | 4 +- .../src/semantic_index/symbol.rs | 76 +- .../src/semantic_index/use_def.rs | 11 +- .../semantic_index/use_def/symbol_state.rs | 2 +- .../semantic_index/visibility_constraints.rs | 6 +- .../ty_python_semantic/src/semantic_model.rs | 6 +- .../ty_python_semantic/src/site_packages.rs | 12 +- crates/ty_python_semantic/src/suppression.rs | 4 +- crates/ty_python_semantic/src/symbol.rs | 20 +- crates/ty_python_semantic/src/types.rs | 66 +- .../ty_python_semantic/src/types/call/bind.rs | 71 +- crates/ty_python_semantic/src/types/class.rs | 24 +- .../src/types/class_base.rs | 4 +- .../ty_python_semantic/src/types/context.rs | 8 +- .../src/types/diagnostic.rs | 6 +- .../ty_python_semantic/src/types/display.rs | 2 +- .../ty_python_semantic/src/types/generics.rs | 4 +- crates/ty_python_semantic/src/types/infer.rs | 150 ++- .../ty_python_semantic/src/types/instance.rs | 2 +- .../src/types/known_instance.rs | 4 +- crates/ty_python_semantic/src/types/mro.rs | 2 +- crates/ty_python_semantic/src/types/narrow.rs | 8 +- .../src/types/property_tests/setup.rs | 2 +- .../src/types/signatures.rs | 74 +- .../src/types/type_ordering.rs | 4 +- .../ty_python_semantic/src/types/unpacker.rs | 4 +- crates/ty_python_semantic/src/unpack.rs | 2 +- crates/ty_python_semantic/tests/mdtest.rs | 2 +- crates/ty_server/src/document/location.rs | 2 +- crates/ty_server/src/document/range.rs | 4 +- .../ty_server/src/document/text_document.rs | 8 +- crates/ty_server/src/logging.rs | 2 +- crates/ty_server/src/server.rs | 6 +- crates/ty_server/src/server/api.rs | 4 +- .../ty_server/src/server/api/diagnostics.rs | 4 +- .../server/api/notifications/did_change.rs | 10 +- .../notifications/did_change_watched_files.rs | 10 +- .../src/server/api/notifications/did_close.rs | 8 +- .../api/notifications/did_close_notebook.rs | 10 +- .../src/server/api/notifications/did_open.rs | 6 +- .../api/notifications/did_open_notebook.rs | 10 +- .../src/server/api/requests/completion.rs | 2 +- .../src/server/api/requests/diagnostic.rs | 2 +- .../api/requests/goto_type_definition.rs | 2 +- .../src/server/api/requests/hover.rs | 4 +- .../src/server/api/requests/inlay_hints.rs | 2 +- crates/ty_server/src/server/client.rs | 2 +- crates/ty_server/src/server/connection.rs | 4 +- crates/ty_server/src/server/schedule.rs | 2 +- .../src/server/schedule/thread/pool.rs | 2 +- crates/ty_server/src/session.rs | 6 +- crates/ty_server/src/session/index.rs | 2 +- crates/ty_server/src/system.rs | 4 +- crates/ty_test/src/assertion.rs | 12 +- crates/ty_test/src/db.rs | 4 +- crates/ty_test/src/lib.rs | 8 +- crates/ty_test/src/matcher.rs | 4 +- crates/ty_test/src/parser.rs | 27 +- crates/ty_vendored/build.rs | 2 +- crates/ty_wasm/src/lib.rs | 10 +- scripts/add_rule.py | 2 +- 1082 files changed, 4211 insertions(+), 3300 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 484b3b3519..d4232fb7bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -495,7 +495,7 @@ jobs: persist-credentials: false - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 - name: "Install Rust toolchain" - run: rustup component add rustfmt + run: rustup show # Run all code generation scripts, and verify that the current output is # already checked into git. - run: python crates/ruff_python_ast/generate.py @@ -504,12 +504,10 @@ jobs: # Verify that adding a plugin or rule produces clean code. - run: ./scripts/add_rule.py --name DoTheThing --prefix F --code 999 --linter pyflakes - run: cargo check - - run: cargo fmt --all --check - run: | ./scripts/add_plugin.py test --url https://pypi.org/project/-test/0.1.0/ --prefix TST ./scripts/add_rule.py --name FirstRule --prefix TST --code 001 --linter test - run: cargo check - - run: cargo fmt --all --check ecosystem: name: "ecosystem" diff --git a/Cargo.toml b/Cargo.toml index 2704d59a46..285bbd7bf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -edition = "2021" +edition = "2024" rust-version = "1.85" homepage = "https://docs.astral.sh/ruff" documentation = "https://docs.astral.sh/ruff" diff --git a/crates/ruff/src/args.rs b/crates/ruff/src/args.rs index fb2f9a273d..45db84d053 100644 --- a/crates/ruff/src/args.rs +++ b/crates/ruff/src/args.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use crate::commands::completions::config::{OptionString, OptionStringParser}; use anyhow::bail; use clap::builder::{TypedValueParser, ValueParserFactory}; -use clap::{command, Parser, Subcommand}; +use clap::{Parser, Subcommand, command}; use colored::Colorize; use itertools::Itertools; use path_absolutize::path_dedot; @@ -1126,10 +1126,10 @@ impl std::fmt::Display for FormatRangeParseError { write!( f, "the start position '{start_invalid}' is greater than the end position '{end_invalid}'.\n {tip} Try switching start and end: '{end}-{start}'", - start_invalid=start.to_string().bold().yellow(), - end_invalid=end.to_string().bold().yellow(), - start=start.to_string().green().bold(), - end=end.to_string().green().bold() + start_invalid = start.to_string().bold().yellow(), + end_invalid = end.to_string().bold().yellow(), + start = start.to_string().green().bold(), + end = end.to_string().green().bold() ) } FormatRangeParseError::InvalidStart(inner) => inner.write(f, true), @@ -1230,30 +1230,36 @@ impl LineColumnParseError { match self { LineColumnParseError::ColumnParseError(inner) => { - write!(f, "the {range}s column is not a valid number ({inner})'\n {tip} The format is 'line:column'.") + write!( + f, + "the {range}s column is not a valid number ({inner})'\n {tip} The format is 'line:column'." + ) } LineColumnParseError::LineParseError(inner) => { - write!(f, "the {range} line is not a valid number ({inner})\n {tip} The format is 'line:column'.") + write!( + f, + "the {range} line is not a valid number ({inner})\n {tip} The format is 'line:column'." + ) } LineColumnParseError::ZeroColumnIndex { line } => { write!( f, "the {range} column is 0, but it should be 1 or greater.\n {tip} The column numbers start at 1.\n {tip} Try {suggestion} instead.", - suggestion=format!("{line}:1").green().bold() + suggestion = format!("{line}:1").green().bold() ) } LineColumnParseError::ZeroLineIndex { column } => { write!( f, "the {range} line is 0, but it should be 1 or greater.\n {tip} The line numbers start at 1.\n {tip} Try {suggestion} instead.", - suggestion=format!("1:{column}").green().bold() + suggestion = format!("1:{column}").green().bold() ) } LineColumnParseError::ZeroLineAndColumnIndex => { write!( f, "the {range} line and column are both 0, but they should be 1 or greater.\n {tip} The line and column numbers start at 1.\n {tip} Try {suggestion} instead.", - suggestion="1:1".to_string().green().bold() + suggestion = "1:1".to_string().green().bold() ) } } diff --git a/crates/ruff/src/cache.rs b/crates/ruff/src/cache.rs index 99eed7cbaf..056c7420b0 100644 --- a/crates/ruff/src/cache.rs +++ b/crates/ruff/src/cache.rs @@ -3,8 +3,8 @@ use std::fs::{self, File}; use std::hash::Hasher; use std::io::{self, BufReader, Write}; use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Mutex; +use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{Duration, SystemTime}; use anyhow::{Context, Result}; @@ -22,13 +22,13 @@ use ruff_cache::{CacheKey, CacheKeyHasher}; use ruff_diagnostics::Fix; use ruff_linter::message::{DiagnosticMessage, Message}; use ruff_linter::package::PackageRoot; -use ruff_linter::{warn_user, VERSION}; +use ruff_linter::{VERSION, warn_user}; use ruff_macros::CacheKey; use ruff_notebook::NotebookIndex; use ruff_source_file::SourceFileBuilder; use ruff_text_size::{TextRange, TextSize}; -use ruff_workspace::resolver::Resolver; use ruff_workspace::Settings; +use ruff_workspace::resolver::Resolver; use crate::diagnostics::Diagnostics; @@ -597,7 +597,7 @@ mod tests { use std::time::SystemTime; use anyhow::Result; - use filetime::{set_file_mtime, FileTime}; + use filetime::{FileTime, set_file_mtime}; use itertools::Itertools; use ruff_linter::settings::LinterSettings; use test_case::test_case; @@ -612,8 +612,8 @@ mod tests { use crate::cache::{self, FileCache, FileCacheData, FileCacheKey}; use crate::cache::{Cache, RelativePathBuf}; - use crate::commands::format::{format_path, FormatCommandError, FormatMode, FormatResult}; - use crate::diagnostics::{lint_path, Diagnostics}; + use crate::commands::format::{FormatCommandError, FormatMode, FormatResult, format_path}; + use crate::diagnostics::{Diagnostics, lint_path}; #[test_case("../ruff_linter/resources/test/fixtures", "ruff_tests/cache_same_results_ruff_linter"; "ruff_linter_fixtures")] #[test_case("../ruff_notebook/resources/test/fixtures", "ruff_tests/cache_same_results_ruff_notebook"; "ruff_notebook_fixtures")] diff --git a/crates/ruff/src/commands/add_noqa.rs b/crates/ruff/src/commands/add_noqa.rs index c5a417ec3c..d5eaeb0170 100644 --- a/crates/ruff/src/commands/add_noqa.rs +++ b/crates/ruff/src/commands/add_noqa.rs @@ -11,7 +11,7 @@ use ruff_linter::source_kind::SourceKind; use ruff_linter::warn_user_once; use ruff_python_ast::{PySourceType, SourceType}; use ruff_workspace::resolver::{ - match_exclusion, python_files_in_path, PyprojectConfig, ResolvedFile, + PyprojectConfig, ResolvedFile, match_exclusion, python_files_in_path, }; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/commands/analyze_graph.rs b/crates/ruff/src/commands/analyze_graph.rs index d0bf72edf7..75ff28d0dc 100644 --- a/crates/ruff/src/commands/analyze_graph.rs +++ b/crates/ruff/src/commands/analyze_graph.rs @@ -1,6 +1,6 @@ use crate::args::{AnalyzeGraphArgs, ConfigArguments}; use crate::resolve::resolve; -use crate::{resolve_default_files, ExitStatus}; +use crate::{ExitStatus, resolve_default_files}; use anyhow::Result; use log::{debug, warn}; use path_absolutize::CWD; @@ -9,7 +9,7 @@ use ruff_graph::{Direction, ImportMap, ModuleDb, ModuleImports}; use ruff_linter::package::PackageRoot; use ruff_linter::{warn_user, warn_user_once}; use ruff_python_ast::{PySourceType, SourceType}; -use ruff_workspace::resolver::{match_exclusion, python_files_in_path, ResolvedFile}; +use ruff_workspace::resolver::{ResolvedFile, match_exclusion, python_files_in_path}; use rustc_hash::FxHashMap; use std::io::Write; use std::path::{Path, PathBuf}; diff --git a/crates/ruff/src/commands/check.rs b/crates/ruff/src/commands/check.rs index 9b7104e4dc..72ae7162d9 100644 --- a/crates/ruff/src/commands/check.rs +++ b/crates/ruff/src/commands/check.rs @@ -17,12 +17,12 @@ use ruff_linter::message::Message; use ruff_linter::package::PackageRoot; use ruff_linter::registry::Rule; use ruff_linter::settings::types::UnsafeFixes; -use ruff_linter::settings::{flags, LinterSettings}; -use ruff_linter::{fs, warn_user_once, IOError}; +use ruff_linter::settings::{LinterSettings, flags}; +use ruff_linter::{IOError, fs, warn_user_once}; use ruff_source_file::SourceFileBuilder; use ruff_text_size::{TextRange, TextSize}; use ruff_workspace::resolver::{ - match_exclusion, python_files_in_path, PyprojectConfig, ResolvedFile, + PyprojectConfig, ResolvedFile, match_exclusion, python_files_in_path, }; use crate::args::ConfigArguments; @@ -228,9 +228,9 @@ mod test { use ruff_linter::message::{Emitter, EmitterContext, TextEmitter}; use ruff_linter::registry::Rule; use ruff_linter::settings::types::UnsafeFixes; - use ruff_linter::settings::{flags, LinterSettings}; - use ruff_workspace::resolver::{PyprojectConfig, PyprojectDiscoveryStrategy}; + use ruff_linter::settings::{LinterSettings, flags}; use ruff_workspace::Settings; + use ruff_workspace::resolver::{PyprojectConfig, PyprojectDiscoveryStrategy}; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/commands/check_stdin.rs b/crates/ruff/src/commands/check_stdin.rs index 4e7be0b540..4b01943353 100644 --- a/crates/ruff/src/commands/check_stdin.rs +++ b/crates/ruff/src/commands/check_stdin.rs @@ -4,10 +4,10 @@ use anyhow::Result; use ruff_linter::package::PackageRoot; use ruff_linter::packaging; use ruff_linter::settings::flags; -use ruff_workspace::resolver::{match_exclusion, python_file_at_path, PyprojectConfig, Resolver}; +use ruff_workspace::resolver::{PyprojectConfig, Resolver, match_exclusion, python_file_at_path}; use crate::args::ConfigArguments; -use crate::diagnostics::{lint_stdin, Diagnostics}; +use crate::diagnostics::{Diagnostics, lint_stdin}; use crate::stdin::{parrot_stdin, read_from_stdin}; /// Run the linter over a single file, read from `stdin`. diff --git a/crates/ruff/src/commands/config.rs b/crates/ruff/src/commands/config.rs index 98bd9d70ae..f6c0054839 100644 --- a/crates/ruff/src/commands/config.rs +++ b/crates/ruff/src/commands/config.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use crate::args::HelpFormat; diff --git a/crates/ruff/src/commands/format.rs b/crates/ruff/src/commands/format.rs index 57414c249d..a09fb9b804 100644 --- a/crates/ruff/src/commands/format.rs +++ b/crates/ruff/src/commands/format.rs @@ -1,7 +1,7 @@ use std::fmt::{Display, Formatter}; use std::fs::File; use std::io; -use std::io::{stderr, stdout, Write}; +use std::io::{Write, stderr, stdout}; use std::path::{Path, PathBuf}; use std::time::Instant; @@ -16,7 +16,7 @@ use rustc_hash::FxHashSet; use thiserror::Error; use tracing::debug; -use ruff_db::panic::{catch_unwind, PanicError}; +use ruff_db::panic::{PanicError, catch_unwind}; use ruff_diagnostics::SourceMap; use ruff_linter::fs; use ruff_linter::logging::{DisplayParseError, LogLevel}; @@ -26,16 +26,16 @@ use ruff_linter::rules::flake8_quotes::settings::Quote; use ruff_linter::source_kind::{SourceError, SourceKind}; use ruff_linter::warn_user_once; use ruff_python_ast::{PySourceType, SourceType}; -use ruff_python_formatter::{format_module_source, format_range, FormatModuleError, QuoteStyle}; +use ruff_python_formatter::{FormatModuleError, QuoteStyle, format_module_source, format_range}; use ruff_source_file::LineIndex; use ruff_text_size::{TextLen, TextRange, TextSize}; -use ruff_workspace::resolver::{match_exclusion, python_files_in_path, ResolvedFile, Resolver}; use ruff_workspace::FormatterSettings; +use ruff_workspace::resolver::{ResolvedFile, Resolver, match_exclusion, python_files_in_path}; use crate::args::{ConfigArguments, FormatArguments, FormatRange}; use crate::cache::{Cache, FileCacheKey, PackageCacheMap, PackageCaches}; use crate::resolve::resolve; -use crate::{resolve_default_files, ExitStatus}; +use crate::{ExitStatus, resolve_default_files}; #[derive(Debug, Copy, Clone, is_macro::Is)] pub(crate) enum FormatMode { @@ -821,9 +821,14 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { .collect(); rule_names.sort(); if let [rule] = rule_names.as_slice() { - warn_user_once!("The following rule may cause conflicts when used with the formatter: {rule}. To avoid unexpected behavior, we recommend disabling this rule, either by removing it from the `select` or `extend-select` configuration, or adding it to the `ignore` configuration."); + warn_user_once!( + "The following rule may cause conflicts when used with the formatter: {rule}. To avoid unexpected behavior, we recommend disabling this rule, either by removing it from the `select` or `extend-select` configuration, or adding it to the `ignore` configuration." + ); } else { - warn_user_once!("The following rules may cause conflicts when used with the formatter: {}. To avoid unexpected behavior, we recommend disabling these rules, either by removing them from the `select` or `extend-select` configuration, or adding them to the `ignore` configuration.", rule_names.join(", ")); + warn_user_once!( + "The following rules may cause conflicts when used with the formatter: {}. To avoid unexpected behavior, we recommend disabling these rules, either by removing them from the `select` or `extend-select` configuration, or adding them to the `ignore` configuration.", + rule_names.join(", ") + ); } } @@ -833,7 +838,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { if setting.linter.rules.enabled(Rule::TabIndentation) && setting.formatter.indent_style.is_tab() { - warn_user_once!("The `format.indent-style=\"tab\"` option is incompatible with `W191`, which lints against all uses of tabs. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`."); + warn_user_once!( + "The `format.indent-style=\"tab\"` option is incompatible with `W191`, which lints against all uses of tabs. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`." + ); } if !setting @@ -846,14 +853,18 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { .enabled(Rule::MultiLineImplicitStringConcatenation) && !setting.linter.flake8_implicit_str_concat.allow_multiline { - warn_user_once!("The `lint.flake8-implicit-str-concat.allow-multiline = false` option is incompatible with the formatter unless `ISC001` is enabled. We recommend enabling `ISC001` or setting `allow-multiline=true`."); + warn_user_once!( + "The `lint.flake8-implicit-str-concat.allow-multiline = false` option is incompatible with the formatter unless `ISC001` is enabled. We recommend enabling `ISC001` or setting `allow-multiline=true`." + ); } // Validate all rules that rely on tab styles. if setting.linter.rules.enabled(Rule::DocstringTabIndentation) && setting.formatter.indent_style.is_tab() { - warn_user_once!("The `format.indent-style=\"tab\"` option is incompatible with `D206`, with requires space-based indentation. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`."); + warn_user_once!( + "The `format.indent-style=\"tab\"` option is incompatible with `D206`, with requires space-based indentation. We recommend disabling these rules when using the formatter, which enforces a consistent indentation style. Alternatively, set the `format.indent-style` option to `\"space\"`." + ); } // Validate all rules that rely on custom indent widths. @@ -862,7 +873,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { Rule::IndentationWithInvalidMultipleComment, ]) && setting.formatter.indent_width.value() != 4 { - warn_user_once!("The `format.indent-width` option with a value other than 4 is incompatible with `E111` and `E114`. We recommend disabling these rules when using the formatter, which enforces a consistent indentation width. Alternatively, set the `format.indent-width` option to `4`."); + warn_user_once!( + "The `format.indent-width` option with a value other than 4 is incompatible with `E111` and `E114`. We recommend disabling these rules when using the formatter, which enforces a consistent indentation width. Alternatively, set the `format.indent-width` option to `4`." + ); } // Validate all rules that rely on quote styles. @@ -876,10 +889,14 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { setting.formatter.quote_style, ) { (Quote::Double, QuoteStyle::Single) => { - warn_user_once!("The `flake8-quotes.inline-quotes=\"double\"` option is incompatible with the formatter's `format.quote-style=\"single\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`."); + warn_user_once!( + "The `flake8-quotes.inline-quotes=\"double\"` option is incompatible with the formatter's `format.quote-style=\"single\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`." + ); } (Quote::Single, QuoteStyle::Double) => { - warn_user_once!("The `flake8-quotes.inline-quotes=\"single\"` option is incompatible with the formatter's `format.quote-style=\"double\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`."); + warn_user_once!( + "The `flake8-quotes.inline-quotes=\"single\"` option is incompatible with the formatter's `format.quote-style=\"double\"`. We recommend disabling `Q000` and `Q003` when using the formatter, which enforces a consistent quote style. Alternatively, set both options to either `\"single\"` or `\"double\"`." + ); } _ => {} } @@ -892,7 +909,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { QuoteStyle::Single | QuoteStyle::Double ) { - warn_user_once!("The `flake8-quotes.multiline-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q001` when using the formatter, which enforces double quotes for multiline strings. Alternatively, set the `flake8-quotes.multiline-quotes` option to `\"double\"`.`"); + warn_user_once!( + "The `flake8-quotes.multiline-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q001` when using the formatter, which enforces double quotes for multiline strings. Alternatively, set the `flake8-quotes.multiline-quotes` option to `\"double\"`.`" + ); } if setting.linter.rules.enabled(Rule::BadQuotesDocstring) @@ -902,7 +921,9 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { QuoteStyle::Single | QuoteStyle::Double ) { - warn_user_once!("The `flake8-quotes.docstring-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q002` when using the formatter, which enforces double quotes for docstrings. Alternatively, set the `flake8-quotes.docstring-quotes` option to `\"double\"`.`"); + warn_user_once!( + "The `flake8-quotes.docstring-quotes=\"single\"` option is incompatible with the formatter. We recommend disabling `Q002` when using the formatter, which enforces double quotes for docstrings. Alternatively, set the `flake8-quotes.docstring-quotes` option to `\"double\"`.`" + ); } // Validate all isort settings. @@ -910,12 +931,16 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { // The formatter removes empty lines if the value is larger than 2 but always inserts a empty line after imports. // Two empty lines are okay because `isort` only uses this setting for top-level imports (not in nested blocks). if !matches!(setting.linter.isort.lines_after_imports, 1 | 2 | -1) { - warn_user_once!("The isort option `isort.lines-after-imports` with a value other than `-1`, `1` or `2` is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `2`, `1`, or `-1` (default)."); + warn_user_once!( + "The isort option `isort.lines-after-imports` with a value other than `-1`, `1` or `2` is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `2`, `1`, or `-1` (default)." + ); } // Values larger than two get reduced to one line by the formatter if the import is in a nested block. if setting.linter.isort.lines_between_types > 1 { - warn_user_once!("The isort option `isort.lines-between-types` with a value greater than 1 is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `1` or `0` (default)."); + warn_user_once!( + "The isort option `isort.lines-between-types` with a value greater than 1 is incompatible with the formatter. To avoid unexpected behavior, we recommend setting the option to one of: `1` or `0` (default)." + ); } // isort inserts a trailing comma which the formatter preserves, but only if `skip-magic-trailing-comma` isn't false. @@ -924,11 +949,15 @@ pub(super) fn warn_incompatible_formatter_settings(resolver: &Resolver) { && !setting.linter.isort.force_single_line { if setting.linter.isort.force_wrap_aliases { - warn_user_once!("The isort option `isort.force-wrap-aliases` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.force-wrap-aliases=false` or `format.skip-magic-trailing-comma=false`."); + warn_user_once!( + "The isort option `isort.force-wrap-aliases` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.force-wrap-aliases=false` or `format.skip-magic-trailing-comma=false`." + ); } if setting.linter.isort.split_on_trailing_comma { - warn_user_once!("The isort option `isort.split-on-trailing-comma` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.split-on-trailing-comma=false` or `format.skip-magic-trailing-comma=false`."); + warn_user_once!( + "The isort option `isort.split-on-trailing-comma` is incompatible with the formatter `format.skip-magic-trailing-comma=true` option. To avoid unexpected behavior, we recommend either setting `isort.split-on-trailing-comma=false` or `format.skip-magic-trailing-comma=false`." + ); } } } diff --git a/crates/ruff/src/commands/format_stdin.rs b/crates/ruff/src/commands/format_stdin.rs index 9c2d8ff3e0..f5b8ea6c60 100644 --- a/crates/ruff/src/commands/format_stdin.rs +++ b/crates/ruff/src/commands/format_stdin.rs @@ -6,17 +6,17 @@ use log::error; use ruff_linter::source_kind::SourceKind; use ruff_python_ast::{PySourceType, SourceType}; -use ruff_workspace::resolver::{match_exclusion, python_file_at_path, Resolver}; use ruff_workspace::FormatterSettings; +use ruff_workspace::resolver::{Resolver, match_exclusion, python_file_at_path}; +use crate::ExitStatus; use crate::args::{ConfigArguments, FormatArguments, FormatRange}; use crate::commands::format::{ - format_source, warn_incompatible_formatter_settings, FormatCommandError, FormatMode, - FormatResult, FormattedSource, + FormatCommandError, FormatMode, FormatResult, FormattedSource, format_source, + warn_incompatible_formatter_settings, }; use crate::resolve::resolve; use crate::stdin::{parrot_stdin, read_from_stdin}; -use crate::ExitStatus; /// Run the formatter over a single file, read from `stdin`. pub(crate) fn format_stdin( diff --git a/crates/ruff/src/commands/show_files.rs b/crates/ruff/src/commands/show_files.rs index f21a9aa943..7c74837fd3 100644 --- a/crates/ruff/src/commands/show_files.rs +++ b/crates/ruff/src/commands/show_files.rs @@ -5,7 +5,7 @@ use anyhow::Result; use itertools::Itertools; use ruff_linter::warn_user_once; -use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig, ResolvedFile}; +use ruff_workspace::resolver::{PyprojectConfig, ResolvedFile, python_files_in_path}; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/commands/show_settings.rs b/crates/ruff/src/commands/show_settings.rs index 679c2733df..ec4b0d5482 100644 --- a/crates/ruff/src/commands/show_settings.rs +++ b/crates/ruff/src/commands/show_settings.rs @@ -1,10 +1,10 @@ use std::io::Write; use std::path::PathBuf; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use itertools::Itertools; -use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig, ResolvedFile}; +use ruff_workspace::resolver::{PyprojectConfig, ResolvedFile, python_files_in_path}; use crate::args::ConfigArguments; diff --git a/crates/ruff/src/diagnostics.rs b/crates/ruff/src/diagnostics.rs index 4610eca5c4..5ce39f49a8 100644 --- a/crates/ruff/src/diagnostics.rs +++ b/crates/ruff/src/diagnostics.rs @@ -14,14 +14,14 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::Diagnostic; use ruff_linter::codes::Rule; -use ruff_linter::linter::{lint_fix, lint_only, FixTable, FixerResult, LinterResult, ParseSource}; +use ruff_linter::linter::{FixTable, FixerResult, LinterResult, ParseSource, lint_fix, lint_only}; use ruff_linter::message::Message; use ruff_linter::package::PackageRoot; use ruff_linter::pyproject_toml::lint_pyproject_toml; use ruff_linter::settings::types::UnsafeFixes; -use ruff_linter::settings::{flags, LinterSettings}; +use ruff_linter::settings::{LinterSettings, flags}; use ruff_linter::source_kind::{SourceError, SourceKind}; -use ruff_linter::{fs, IOError}; +use ruff_linter::{IOError, fs}; use ruff_notebook::{Notebook, NotebookError, NotebookIndex}; use ruff_python_ast::{PySourceType, SourceType, TomlSourceType}; use ruff_source_file::SourceFileBuilder; diff --git a/crates/ruff/src/lib.rs b/crates/ruff/src/lib.rs index 11c7ba3e70..ef8f639746 100644 --- a/crates/ruff/src/lib.rs +++ b/crates/ruff/src/lib.rs @@ -1,7 +1,7 @@ #![allow(clippy::print_stdout)] use std::fs::File; -use std::io::{self, stdout, BufWriter, Write}; +use std::io::{self, BufWriter, Write, stdout}; use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; use std::process::ExitCode; @@ -11,10 +11,10 @@ use anyhow::Result; use clap::CommandFactory; use colored::Colorize; use log::warn; -use notify::{recommended_watcher, RecursiveMode, Watcher}; +use notify::{RecursiveMode, Watcher, recommended_watcher}; use args::{GlobalConfigArgs, ServerCommand}; -use ruff_linter::logging::{set_up_logging, LogLevel}; +use ruff_linter::logging::{LogLevel, set_up_logging}; use ruff_linter::settings::flags::FixMode; use ruff_linter::settings::types::OutputFormat; use ruff_linter::{fs, warn_user, warn_user_once}; @@ -488,7 +488,7 @@ pub fn check(args: CheckCommand, global_options: GlobalConfigArgs) -> Result