From 3ed707f2457a464b7c3bbe120c40a6badf81c270 Mon Sep 17 00:00:00 2001 From: Auguste Lalande Date: Tue, 12 Mar 2024 22:34:23 -0400 Subject: [PATCH] Spellcheck & grammar (#10375) ## Summary I used `codespell` and `gramma` to identify mispellings and grammar errors throughout the codebase and fixed them. I tried not to make any controversial changes, but feel free to revert as you see fit. --- crates/ruff/tests/format.rs | 4 ++-- crates/ruff_formatter/src/buffer.rs | 2 +- .../test/fixtures/pycodestyle/W505.py | 2 +- .../test/fixtures/pycodestyle/W505_utf_8.py | 2 +- .../resources/test/fixtures/ruff/RUF021.py | 2 +- .../resources/test/fixtures/ruff/RUF022.py | 2 +- .../flake8_annotations/rules/definition.rs | 2 +- .../rules/logging_config_insecure_listen.rs | 2 +- .../flake8_bandit/rules/shell_injection.rs | 2 +- .../rules/ssh_no_host_key_verification.rs | 2 +- .../rules/suspicious_function_call.rs | 8 ++++---- .../flake8_bandit/rules/suspicious_imports.rs | 2 +- .../rules/unnecessary_collection_call.rs | 2 +- .../rules/model_without_dunder_str.rs | 6 +++--- .../rules/multiple_starts_ends_with.rs | 2 +- .../rules/unnecessary_literal_union.rs | 2 +- .../flake8_pytest_style/rules/parametrize.rs | 4 ++-- .../src/rules/flake8_return/rules/function.rs | 2 +- .../rules/flake8_simplify/rules/ast_ifexp.rs | 2 +- .../flake8_tidy_imports/rules/banned_api.rs | 5 ++--- .../flake8_use_pathlib/rules/glob_rule.rs | 2 +- .../numpy/rules/deprecated_type_alias.rs | 2 +- .../src/rules/pandas_vet/rules/attr.rs | 2 +- .../pep8_naming/rules/invalid_module_name.rs | 2 +- .../rules/pycodestyle/rules/blank_lines.rs | 4 ++-- .../rules/missing_newline_at_end_of_file.rs | 5 +++-- ...s__pycodestyle__tests__max_doc_length.snap | 8 +++----- ...yle__tests__max_doc_length_with_utf_8.snap | 8 +++----- .../rules/blank_before_after_class.rs | 2 +- .../src/rules/pydocstyle/rules/not_missing.rs | 2 +- .../pylint/rules/compare_to_empty_string.rs | 4 ++-- .../rules/redefined_argument_from_local.rs | 4 ++-- .../rules/pylint/rules/redefined_loop_name.rs | 2 +- ...y_iterable_allocation_for_first_element.rs | 2 +- ..._rules__ruff__tests__RUF021_RUF021.py.snap | 8 +++----- crates/ruff_macros/src/lib.rs | 2 +- crates/ruff_notebook/src/notebook.rs | 4 ++-- .../fixtures/black/cases/line_ranges_basic.py | 2 +- .../black/cases/line_ranges_basic.py.expect | 2 +- .../cases/pep604_union_types_line_breaks.py | 2 +- .../pep604_union_types_line_breaks.py.expect | 2 +- .../resources/test/fixtures/ruff/docstring.py | 2 +- .../test/fixtures/ruff/expression/fstring.py | 4 ++-- .../fixtures/ruff/expression/fstring_py312.py | 2 +- .../fixtures/ruff/fmt_on_off/no_fmt_on.py | 2 +- .../test/fixtures/ruff/fmt_on_off/simple.py | 4 ++-- .../test/fixtures/ruff/fmt_on_off/yapf.py | 6 +++--- .../ruff/range_formatting/clause_header.py | 2 +- .../statement/assignment_split_value_first.py | 2 +- .../test/fixtures/ruff/statement/raise.py | 8 ++++---- .../ruff_python_formatter/src/comments/map.rs | 2 +- ...es__pep604_union_types_line_breaks.py.snap | 8 +++----- .../tests/snapshots/format@docstring.py.snap | 15 ++++++--------- .../format@expression__fstring.py.snap | 19 ++++++++----------- .../format@expression__fstring_py312.py.snap | 9 +++------ .../format@fmt_on_off__no_fmt_on.py.snap | 7 ++----- .../format@fmt_on_off__simple.py.snap | 11 ++++------- .../snapshots/format@fmt_on_off__yapf.py.snap | 15 ++++++--------- ...at@range_formatting__clause_header.py.snap | 7 ++----- ...ment__assignment_split_value_first.py.snap | 7 ++----- .../snapshots/format@statement__raise.py.snap | 19 ++++++++----------- crates/ruff_python_parser/src/python.lalrpop | 2 +- crates/ruff_python_parser/src/python.rs | 2 +- crates/ruff_server/src/server/api.rs | 4 ++-- docs/formatter.md | 2 +- docs/preview.md | 2 +- docs/versioning.md | 14 +++++++------- 67 files changed, 135 insertions(+), 170 deletions(-) diff --git a/crates/ruff/tests/format.rs b/crates/ruff/tests/format.rs index 8301e789abcd2..f4a9808a5d1db 100644 --- a/crates/ruff/tests/format.rs +++ b/crates/ruff/tests/format.rs @@ -23,7 +23,7 @@ fn default_options() { .arg("-") .pass_stdin(r#" def foo(arg1, arg2,): - print('Should\'t change quotes') + print('Shouldn\'t change quotes') if condition: @@ -38,7 +38,7 @@ if condition: arg1, arg2, ): - print("Should't change quotes") + print("Shouldn't change quotes") if condition: diff --git a/crates/ruff_formatter/src/buffer.rs b/crates/ruff_formatter/src/buffer.rs index 80ba8f15e7e36..b636216dd08bc 100644 --- a/crates/ruff_formatter/src/buffer.rs +++ b/crates/ruff_formatter/src/buffer.rs @@ -37,7 +37,7 @@ pub trait Buffer { #[doc(hidden)] fn elements(&self) -> &[FormatElement]; - /// Glue for usage of the [`write!`] macro with implementors of this trait. + /// Glue for usage of the [`write!`] macro with implementers of this trait. /// /// This method should generally not be invoked manually, but rather through the [`write!`] macro itself. /// diff --git a/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505.py index c297b8c1e9e89..1b01f831ddf1a 100644 --- a/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505.py +++ b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505.py @@ -10,7 +10,7 @@ def f1(): # Here's a standalone comment that's over the limit. x = 2 - # Another standalone that is preceded by a newline and indent toke and is over the limit. + # Another standalone that is preceded by a newline and indent token and is over the limit. print("Here's a string that's over the limit, but it's not a docstring.") diff --git a/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505_utf_8.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505_utf_8.py index 6e177dad8f0ea..ae1e9f5108281 100644 --- a/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505_utf_8.py +++ b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505_utf_8.py @@ -10,7 +10,7 @@ def f1(): # Here's a standalone comment that's over theß9💣2ℝ. x = 2 - # Another standalone that is preceded by a newline and indent toke and is over theß9💣2ℝ. + # Another standalone that is preceded by a newline and indent token and is over theß9💣2ℝ. print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.") diff --git a/crates/ruff_linter/resources/test/fixtures/ruff/RUF021.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF021.py index b10f3fae24f28..7485e80941fe1 100644 --- a/crates/ruff_linter/resources/test/fixtures/ruff/RUF021.py +++ b/crates/ruff_linter/resources/test/fixtures/ruff/RUF021.py @@ -47,7 +47,7 @@ and some_third_reasonably_long_condition or some_fourth_reasonably_long_condition and some_fifth_reasonably_long_condition - # a commment + # a comment and some_sixth_reasonably_long_condition and some_seventh_reasonably_long_condition # another comment diff --git a/crates/ruff_linter/resources/test/fixtures/ruff/RUF022.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF022.py index 2c192bad7aef1..a5c35ef2a2125 100644 --- a/crates/ruff_linter/resources/test/fixtures/ruff/RUF022.py +++ b/crates/ruff_linter/resources/test/fixtures/ruff/RUF022.py @@ -48,7 +48,7 @@ # we implement an "isort-style sort": # SCEAMING_CASE constants first, # then CamelCase classes, -# then anything thats lowercase_snake_case. +# then anything that's lowercase_snake_case. # This (which is currently alphabetically sorted) # should get reordered accordingly: __all__ = [ diff --git a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs index d8a9ea42ee3bb..f847fd6954eed 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs @@ -294,7 +294,7 @@ impl Violation for MissingReturnTypePrivateFunction { /// /// Note that type checkers often allow you to omit the return type annotation for /// `__init__` methods, as long as at least one argument has a type annotation. To -/// opt-in to this behavior, use the `mypy-init-return` setting in your `pyproject.toml` +/// opt in to this behavior, use the `mypy-init-return` setting in your `pyproject.toml` /// or `ruff.toml` file: /// /// ```toml diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs index d92eb3466dfdf..c25a846a6db26 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs @@ -11,7 +11,7 @@ use crate::checkers::ast::Checker; /// /// ## Why is this bad? /// `logging.config.listen` starts a server that listens for logging -/// configuration requests. This is insecure as parts of the configuration are +/// configuration requests. This is insecure, as parts of the configuration are /// passed to the built-in `eval` function, which can be used to execute /// arbitrary code. /// diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/shell_injection.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/shell_injection.rs index 4d0df15f387e4..d1e5d9a852a3d 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/shell_injection.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/shell_injection.rs @@ -222,7 +222,7 @@ impl Violation for StartProcessWithNoShell { /// /// ## Why is this bad? /// Starting a process with a partial executable path can allow attackers to -/// execute arbitrary executable by adjusting the `PATH` environment variable. +/// execute an arbitrary executable by adjusting the `PATH` environment variable. /// Consider using a full path to the executable instead. /// /// ## Example diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs index 8084aa0676ec1..848075fc20ac1 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs @@ -11,7 +11,7 @@ use crate::checkers::ast::Checker; /// Checks for uses of policies disabling SSH verification in Paramiko. /// /// ## Why is this bad? -/// By default, Paramiko checks the identity of remote host when establishing +/// By default, Paramiko checks the identity of the remote host when establishing /// an SSH connection. Disabling the verification might lead to the client /// connecting to a malicious host, without the client knowing. /// diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs index 4b90142a19536..63fba09cb9f83 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs @@ -59,7 +59,7 @@ impl Violation for SuspiciousPickleUsage { /// Checks for calls to `marshal` functions. /// /// ## Why is this bad? -/// Deserializing untrusted data with `marshal` is insecure as it can allow for +/// Deserializing untrusted data with `marshal` is insecure, as it can allow for /// the creation of arbitrary objects, which can then be used to achieve /// arbitrary code execution and otherwise unexpected behavior. /// @@ -68,7 +68,7 @@ impl Violation for SuspiciousPickleUsage { /// /// If you must deserialize untrusted data with `marshal`, consider signing the /// data with a secret key and verifying the signature before deserializing the -/// payload, This will prevent an attacker from injecting arbitrary objects +/// payload. This will prevent an attacker from injecting arbitrary objects /// into the serialized data. /// /// ## Example @@ -353,7 +353,7 @@ impl Violation for SuspiciousMarkSafeUsage { /// behavior. /// /// To mitigate this risk, audit all uses of URL open functions and ensure that -/// only permitted schemes are used (e.g., allowing `http:` and `https:` and +/// only permitted schemes are used (e.g., allowing `http:` and `https:`, and /// disallowing `file:` and `ftp:`). /// /// ## Example @@ -395,7 +395,7 @@ impl Violation for SuspiciousURLOpenUsage { /// Checks for uses of cryptographically weak pseudo-random number generators. /// /// ## Why is this bad? -/// Cryptographically weak pseudo-random number generators are insecure as they +/// Cryptographically weak pseudo-random number generators are insecure, as they /// are easily predictable. This can allow an attacker to guess the generated /// numbers and compromise the security of the system. /// diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs index f77b8bc2724a2..1754f1ac6e242 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs @@ -245,7 +245,7 @@ impl Violation for SuspiciousLxmlImport { /// Checks for imports of the `xmlrpc` module. /// /// ## Why is this bad? -/// XMLRPC is a particularly dangerous XML module as it is also concerned with +/// XMLRPC is a particularly dangerous XML module, as it is also concerned with /// communicating data over a network. Use the `defused.xmlrpc.monkey_patch()` /// function to monkey-patch the `xmlrpclib` module and mitigate remote XML /// attacks. diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs index f676cb598b750..717325ef2155e 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs @@ -13,7 +13,7 @@ use crate::rules::flake8_comprehensions::settings::Settings; /// rewritten as empty literals. /// /// ## Why is this bad? -/// It's unnecessary to call e.g., `dict()` as opposed to using an empty +/// It's unnecessary to call, e.g., `dict()` as opposed to using an empty /// literal (`{}`). The former is slower because the name `dict` must be /// looked up in the global scope in case it has been rebound. /// diff --git a/crates/ruff_linter/src/rules/flake8_django/rules/model_without_dunder_str.rs b/crates/ruff_linter/src/rules/flake8_django/rules/model_without_dunder_str.rs index 47e468414fc9a..3e16d3e66cfbc 100644 --- a/crates/ruff_linter/src/rules/flake8_django/rules/model_without_dunder_str.rs +++ b/crates/ruff_linter/src/rules/flake8_django/rules/model_without_dunder_str.rs @@ -10,14 +10,14 @@ use crate::checkers::ast::Checker; use super::helpers; /// ## What it does -/// Checks that `__str__` method is defined in Django models. +/// Checks that a `__str__` method is defined in Django models. /// /// ## Why is this bad? -/// Django models should define `__str__` method to return a string representation +/// Django models should define a `__str__` method to return a string representation /// of the model instance, as Django calls this method to display the object in /// the Django Admin and elsewhere. /// -/// Models without `__str__` method will display a non-meaningful representation +/// Models without a `__str__` method will display a non-meaningful representation /// of the object in the Django Admin. /// /// ## Example diff --git a/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs index ba2dc033cf94e..477dd1efee7da 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs +++ b/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs @@ -21,7 +21,7 @@ use crate::checkers::ast::Checker; /// ## Why is this bad? /// The `startswith` and `endswith` methods accept tuples of prefixes or /// suffixes respectively. Passing a tuple of prefixes or suffixes is more -/// more efficient and readable than calling the method multiple times. +/// efficient and readable than calling the method multiple times. /// /// ## Example /// ```python diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs index b3a49d819732c..146e43f26b390 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs @@ -11,7 +11,7 @@ use crate::checkers::ast::Checker; /// Checks for the presence of multiple literal types in a union. /// /// ## Why is this bad? -/// Literal types accept multiple arguments and it is clearer to specify them +/// Literal types accept multiple arguments, and it is clearer to specify them /// as a single literal. /// /// ## Example diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs index 8a575dc9ff52d..6e85204d658ec 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs @@ -103,9 +103,9 @@ impl Violation for PytestParametrizeNamesWrongType { /// of values. /// /// The style for the list of values rows can be configured via the -/// the [`lint.flake8-pytest-style.parametrize-values-type`] setting, while the +/// [`lint.flake8-pytest-style.parametrize-values-type`] setting, while the /// style for each row of values can be configured via the -/// the [`lint.flake8-pytest-style.parametrize-values-row-type`] setting. +/// [`lint.flake8-pytest-style.parametrize-values-row-type`] setting. /// /// For example, [`lint.flake8-pytest-style.parametrize-values-type`] will lead to /// the following expectations: diff --git a/crates/ruff_linter/src/rules/flake8_return/rules/function.rs b/crates/ruff_linter/src/rules/flake8_return/rules/function.rs index 615f83b6b18c0..9e0f90c4077e4 100644 --- a/crates/ruff_linter/src/rules/flake8_return/rules/function.rs +++ b/crates/ruff_linter/src/rules/flake8_return/rules/function.rs @@ -151,7 +151,7 @@ impl AlwaysFixableViolation for ImplicitReturn { /// assigned variable. /// /// ## Why is this bad? -/// The variable assignment is not necessary as the value can be returned +/// The variable assignment is not necessary, as the value can be returned /// directly. /// /// ## Example diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs index 3e246773638e3..1e19f38710e28 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs @@ -61,7 +61,7 @@ impl Violation for IfExprWithTrueFalse { /// condition. /// /// ## Why is this bad? -/// `if` expressions that evaluate to `False` for a truthy condition an `True` +/// `if` expressions that evaluate to `False` for a truthy condition and `True` /// for a falsey condition can be replaced with `not` operators, which are more /// concise and readable. /// diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs index 534d408e16e10..625e7316a48c9 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs @@ -13,15 +13,14 @@ use crate::rules::flake8_tidy_imports::matchers::NameMatchPolicy; /// /// ## Why is this bad? /// Projects may want to ensure that specific modules or module members are -/// not be imported or accessed. +/// not imported or accessed. /// /// Security or other company policies may be a reason to impose /// restrictions on importing external Python libraries. In some cases, /// projects may adopt conventions around the use of certain modules or /// module members that are not enforceable by the language itself. /// -/// This rule enforces certain import conventions project-wide in an -/// automatic way. +/// This rule enforces certain import conventions project-wide automatically. /// /// ## Options /// - `lint.flake8-tidy-imports.banned-api` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/glob_rule.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/glob_rule.rs index 6a318a6aeea5c..4a09654faafd7 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/glob_rule.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/glob_rule.rs @@ -16,7 +16,7 @@ use ruff_macros::{derive_message_formats, violation}; /// /// | | `glob` | `Path.glob` | /// |-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------| -/// | Hidden files | Excludes hidden files by default. From Python 3.11 onwards, the `include_hidden` keyword can used to include hidden directories. | Includes hidden files by default. | +/// | Hidden files | Excludes hidden files by default. From Python 3.11 onwards, the `include_hidden` keyword can be used to include hidden directories. | Includes hidden files by default. | /// | Iterator | `iglob` returns an iterator. Under the hood, `glob` simply converts the iterator to a list. | `Path.glob` returns an iterator. | /// | Working directory | `glob` takes a `root_dir` keyword to set the current working directory. | `Path.rglob` can be used to return the relative path. | /// | Globstar (`**`) | `glob` requires the `recursive` flag to be set to `True` for the `**` pattern to match any files and zero or more directories, subdirectories, and symbolic links. | The `**` pattern in `Path.glob` means "this directory and all subdirectories, recursively". In other words, it enables recursive globbing. | diff --git a/crates/ruff_linter/src/rules/numpy/rules/deprecated_type_alias.rs b/crates/ruff_linter/src/rules/numpy/rules/deprecated_type_alias.rs index 6f91e68eb128b..d0ce7b52bfcdb 100644 --- a/crates/ruff_linter/src/rules/numpy/rules/deprecated_type_alias.rs +++ b/crates/ruff_linter/src/rules/numpy/rules/deprecated_type_alias.rs @@ -15,7 +15,7 @@ use crate::checkers::ast::Checker; /// primarily for historic reasons, and have been a cause of /// frequent confusion for newcomers. /// -/// These aliases were been deprecated in 1.20, and removed in 1.24. +/// These aliases were deprecated in 1.20, and removed in 1.24. /// /// ## Examples /// ```python diff --git a/crates/ruff_linter/src/rules/pandas_vet/rules/attr.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/attr.rs index d70716fa9496e..61af0d2c80df4 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/rules/attr.rs +++ b/crates/ruff_linter/src/rules/pandas_vet/rules/attr.rs @@ -10,7 +10,7 @@ use crate::rules::pandas_vet::helpers::{test_expression, Resolution}; /// Checks for uses of `.values` on Pandas Series and Index objects. /// /// ## Why is this bad? -/// The `.values` attribute is ambiguous as it's return type is unclear. As +/// The `.values` attribute is ambiguous as its return type is unclear. As /// such, it is no longer recommended by the Pandas documentation. /// /// Instead, use `.to_numpy()` to return a NumPy array, or `.array` to return a diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_module_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_module_name.rs index f43c93b31804b..7c8a178b4ab80 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_module_name.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_module_name.rs @@ -21,7 +21,7 @@ use crate::rules::pep8_naming::settings::IgnoreNames; /// > all-lowercase names, although the use of underscores is discouraged. /// > /// > When an extension module written in C or C++ has an accompanying Python module that -/// > provides a higher level (e.g. more object oriented) interface, the C/C++ module has +/// > provides a higher level (e.g. more object-oriented) interface, the C/C++ module has /// > a leading underscore (e.g. `_socket`). /// /// Further, in order for Python modules to be importable, they must be valid diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs index 1ef34f16c8775..4879f1e93d069 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs @@ -241,7 +241,7 @@ impl AlwaysFixableViolation for BlankLineAfterDecorator { /// Checks for missing blank lines after the end of function or class. /// /// ## Why is this bad? -/// PEP 8 recommends using blank lines as following: +/// PEP 8 recommends using blank lines as follows: /// - Two blank lines are expected between functions and classes /// - One blank line is expected between methods of a class. /// @@ -292,7 +292,7 @@ impl AlwaysFixableViolation for BlankLinesAfterFunctionOrClass { /// Checks for 1 blank line between nested function or class definitions. /// /// ## Why is this bad? -/// PEP 8 recommends using blank lines as following: +/// PEP 8 recommends using blank lines as follows: /// - Two blank lines are expected between functions and classes /// - One blank line is expected between methods of a class. /// diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs index f7ee6ae490123..cef5d251df1ce 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs @@ -9,8 +9,9 @@ use ruff_source_file::Locator; /// Checks for files missing a new line at the end of the file. /// /// ## Why is this bad? -/// Trailing blank lines are superfluous. -/// However the last line should end with a new line. +/// Trailing blank lines in a file are superfluous. +/// +/// However, the last line of the file should end with a newline. /// /// ## Example /// ```python diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap index aea858c21f6a6..3b5726d319c2e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap @@ -27,11 +27,11 @@ W505.py:10:51: W505 Doc line too long (56 > 50) 12 | x = 2 | -W505.py:13:51: W505 Doc line too long (93 > 50) +W505.py:13:51: W505 Doc line too long (94 > 50) | 12 | x = 2 -13 | # Another standalone that is preceded by a newline and indent toke and is over the limit. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 +13 | # Another standalone that is preceded by a newline and indent token and is over the limit. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 14 | 15 | print("Here's a string that's over the limit, but it's not a docstring.") | @@ -58,5 +58,3 @@ W505.py:31:51: W505 Doc line too long (85 > 50) 31 | It's over the limit on this line, which isn't the first line in the docstring.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 | - - diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap index 5e9cbc36641e6..a47212461f247 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap @@ -27,11 +27,11 @@ W505_utf_8.py:10:51: W505 Doc line too long (56 > 50) 12 | x = 2 | -W505_utf_8.py:13:51: W505 Doc line too long (93 > 50) +W505_utf_8.py:13:51: W505 Doc line too long (94 > 50) | 12 | x = 2 -13 | # Another standalone that is preceded by a newline and indent toke and is over theß9💣2ℝ. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 +13 | # Another standalone that is preceded by a newline and indent token and is over theß9💣2ℝ. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 14 | 15 | print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.") | @@ -58,5 +58,3 @@ W505_utf_8.py:31:50: W505 Doc line too long (85 > 50) 31 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing.""" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 | - - diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs index 785de77578f8b..4565f12cbc362 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs @@ -60,7 +60,7 @@ impl AlwaysFixableViolation for OneBlankLineBeforeClass { /// /// ## Why is this bad? /// [PEP 257] recommends the use of a blank line to separate a class's -/// docstring its methods. +/// docstring from its methods. /// /// This rule may not apply to all projects; its applicability is a matter of /// convention. By default, this rule is enabled when using the `google` diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs index 312bf596a4237..6d1242887a149 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs @@ -368,7 +368,7 @@ impl Violation for UndocumentedPublicPackage { /// ## Why is this bad? /// Magic methods (methods with names that start and end with double /// underscores) are used to implement operator overloading and other special -/// behavior. Such methods should should be documented via docstrings to +/// behavior. Such methods should be documented via docstrings to /// outline their behavior. /// /// Generally, magic method docstrings should describe the method's behavior, diff --git a/crates/ruff_linter/src/rules/pylint/rules/compare_to_empty_string.rs b/crates/ruff_linter/src/rules/pylint/rules/compare_to_empty_string.rs index cdb703e4b97d9..3b0166bfd9885 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/compare_to_empty_string.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/compare_to_empty_string.rs @@ -13,8 +13,8 @@ use crate::checkers::ast::Checker; /// /// ## Why is this bad? /// An empty string is falsy, so it is unnecessary to compare it to `""`. If -/// the value can be something else Python considers falsy, such as `None` or -/// `0` or another empty container, then the code is not equivalent. +/// the value can be something else Python considers falsy, such as `None`, +/// `0`, or another empty container, then the code is not equivalent. /// /// ## Known problems /// High false positive rate, as the check is context-insensitive and does not diff --git a/crates/ruff_linter/src/rules/pylint/rules/redefined_argument_from_local.rs b/crates/ruff_linter/src/rules/pylint/rules/redefined_argument_from_local.rs index 69778ad6b3112..794a6518afa56 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/redefined_argument_from_local.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/redefined_argument_from_local.rs @@ -6,8 +6,8 @@ use ruff_macros::{derive_message_formats, violation}; /// that redefine function parameters. /// /// ## Why is this bad? -/// Redefined variable can cause unexpected behavior because of overridden function parameter. -/// If nested functions are declared, inner function's body can override outer function's parameter. +/// Redefined variables can cause unexpected behavior because of overridden function parameters. +/// If nested functions are declared, an inner function's body can override an outer function's parameters. /// /// ## Example /// ```python diff --git a/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs b/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs index dc86eb4dd28f6..3ca8936641686 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs @@ -29,7 +29,7 @@ use crate::checkers::ast::Checker; /// into the remainder of the enclosing loop. /// /// While this mistake is easy to spot in small examples, it can be hidden -/// in larger blocks of code where the definition and redefinition of the +/// in larger blocks of code, where the definition and redefinition of the /// variable may not be visible at the same time. /// /// ## Example diff --git a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs index 9448b5dc70d52..81d4e1479e2e1 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs @@ -43,7 +43,7 @@ use crate::fix::snippet::SourceCodeSnippet; /// This rule's fix is marked as unsafe, as migrating from (e.g.) `list(...)[0]` /// to `next(iter(...))` can change the behavior of your program in two ways: /// -/// 1. First, all above mentioned constructs will eagerly evaluate the entire +/// 1. First, all above-mentioned constructs will eagerly evaluate the entire /// collection, while `next(iter(...))` will only evaluate the first /// element. As such, any side effects that occur during iteration will be /// delayed. diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap index 06850c81d2c32..0660b0b97f85a 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap @@ -223,7 +223,7 @@ RUF021.py:46:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 47 |+ and some_third_reasonably_long_condition) 48 48 | or some_fourth_reasonably_long_condition 49 49 | and some_fifth_reasonably_long_condition -50 50 | # a commment +50 50 | # a comment RUF021.py:48:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear | @@ -232,7 +232,7 @@ RUF021.py:48:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 48 | or some_fourth_reasonably_long_condition | ________^ 49 | | and some_fifth_reasonably_long_condition -50 | | # a commment +50 | | # a comment 51 | | and some_sixth_reasonably_long_condition 52 | | and some_seventh_reasonably_long_condition | |______________________________________________^ RUF021 @@ -248,12 +248,10 @@ RUF021.py:48:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 48 |- or some_fourth_reasonably_long_condition 48 |+ or (some_fourth_reasonably_long_condition 49 49 | and some_fifth_reasonably_long_condition -50 50 | # a commment +50 50 | # a comment 51 51 | and some_sixth_reasonably_long_condition 52 |- and some_seventh_reasonably_long_condition 52 |+ and some_seventh_reasonably_long_condition) 53 53 | # another comment 54 54 | or some_eighth_reasonably_long_condition 55 55 | ): - - diff --git a/crates/ruff_macros/src/lib.rs b/crates/ruff_macros/src/lib.rs index ab0e0db842def..04b9109982959 100644 --- a/crates/ruff_macros/src/lib.rs +++ b/crates/ruff_macros/src/lib.rs @@ -92,7 +92,7 @@ pub fn derive_message_formats(_attr: TokenStream, item: TokenStream) -> TokenStr /// /// Good: /// -/// ```ignroe +/// ```ignore /// use ruff_macros::newtype_index; /// /// #[newtype_index] diff --git a/crates/ruff_notebook/src/notebook.rs b/crates/ruff_notebook/src/notebook.rs index 804e921f13286..fef73cd853dfd 100644 --- a/crates/ruff_notebook/src/notebook.rs +++ b/crates/ruff_notebook/src/notebook.rs @@ -85,7 +85,7 @@ impl Notebook { Self::from_reader(Cursor::new(source_code)) } - /// Read a Jupyter Notebook from a [`Read`] implementor. + /// Read a Jupyter Notebook from a [`Read`] implementer. /// /// See also the black implementation /// @@ -386,7 +386,7 @@ impl Notebook { .map_or(true, |language| language.name == "python") } - /// Write the notebook back to the given [`Write`] implementor. + /// Write the notebook back to the given [`Write`] implementer. pub fn write(&self, writer: &mut dyn Write) -> Result<(), NotebookError> { // https://github.com/psf/black/blob/69ca0a4c7a365c5f5eea519a90980bab72cab764/src/black/__init__.py#LL1041 let formatter = serde_json::ser::PrettyFormatter::with_indent(b" "); diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py index c39bb99bcf5a7..3dc4e3af71d0d 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py @@ -6,7 +6,7 @@ def foo2(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parame def foo3(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parameter_6, parameter_7): pass def foo4(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parameter_6, parameter_7): pass -# Adding some unformated code covering a wide range of syntaxes. +# Adding some unformatted code covering a wide range of syntaxes. if True: # Incorrectly indented prefix comments. diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py.expect index 7fdfdfd0dbbae..01c9c002e3264 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py.expect +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_basic.py.expect @@ -28,7 +28,7 @@ def foo3( def foo4(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parameter_6, parameter_7): pass -# Adding some unformated code covering a wide range of syntaxes. +# Adding some unformatted code covering a wide range of syntaxes. if True: # Incorrectly indented prefix comments. diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py index bd3e48417b6b5..930759735bdc7 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py @@ -19,7 +19,7 @@ z: (int) = 2.3 z: ((int)) = foo() -# In case I go for not enforcing parantheses, this might get improved at the same time +# In case I go for not enforcing parentheses, this might get improved at the same time x = ( z == 9999999999999999999999999999999999999999 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py.expect index ab0a4d96772ca..e9c2f75f7e748 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py.expect +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/pep604_union_types_line_breaks.py.expect @@ -28,7 +28,7 @@ z: Short | Short2 | Short3 | Short4 = 8 z: int = 2.3 z: int = foo() -# In case I go for not enforcing parantheses, this might get improved at the same time +# In case I go for not enforcing parentheses, this might get improved at the same time x = ( z == 9999999999999999999999999999999999999999 diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py index 98a5a730f44f6..38f6f263ff127 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py @@ -148,7 +148,7 @@ def tabbed_indent(self): """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - author """ diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py index 6e2f41b3343e4..d5aa13ff0bc0f 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py @@ -189,7 +189,7 @@ yyyyyyyyyyyy ]} ccccccc" -# Remove the parenthese because they aren't required +# Remove the parentheses because they aren't required xxxxxxxxxxxxxxx = ( f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb { xxxxxxxxxxx # comment 14 @@ -214,7 +214,7 @@ # removed once we have a strict parser. x = f"aaaaaaaaa { x ! r }" -# Even in the case of debug expresions, we only need to preserve the whitespace within +# Even in the case of debug expressions, we only need to preserve the whitespace within # the expression part of the replacement field. x = f"aaaaaaaaa { x = ! r }" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py index 00bacce2fa7ad..8ce24fa363574 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring_py312.py @@ -2,5 +2,5 @@ # the target version is 3.12 or later. A user can have 3.12 syntax even if the target # version isn't set. -# Quotes re-use +# Quotes reuse f"{'a'}" diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/no_fmt_on.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/no_fmt_on.py index d2955856e3a8c..29bbbfd863cfc 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/no_fmt_on.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/no_fmt_on.py @@ -5,5 +5,5 @@ def test(): if unformatted + a: pass -# Get's formatted again +# Gets formatted again a + b diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/simple.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/simple.py index dfe64b1c2e66f..593020faa6db8 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/simple.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/simple.py @@ -1,9 +1,9 @@ -# Get's formatted +# Gets formatted a + b # fmt: off a + [1, 2, 3, 4, 5 ] # fmt: on -# Get's formatted again +# Gets formatted again a + b diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/yapf.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/yapf.py index 741ca7213a9a4..ebf9d40246230 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/yapf.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/yapf.py @@ -1,11 +1,11 @@ -# Get's formatted +# Gets formatted a + b # yapf: disable a + [1, 2, 3, 4, 5 ] # yapf: enable -# Get's formatted again +# Gets formatted again a + b @@ -13,5 +13,5 @@ a + [1, 2, 3, 4, 5 ] # fmt: on -# Get's formatted again +# Gets formatted again a + b diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/range_formatting/clause_header.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/range_formatting/clause_header.py index 02a50a824f70a..d30c32f11df71 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/range_formatting/clause_header.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/range_formatting/clause_header.py @@ -12,7 +12,7 @@ class Test(OtherClass)\ def __init__( self): print("hello") -print( "dont' format this") +print( "don't format this") def test2(a, b, c: str, d): diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/assignment_split_value_first.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/assignment_split_value_first.py index eda51256a50e7..9955009f89eb6 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/assignment_split_value_first.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/assignment_split_value_first.py @@ -195,7 +195,7 @@ cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment ) -# Format both as flat, but don't loos the comment. +# Format both as flat, but don't lose the comment. a[aaaaaaa, b] = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # comment ####################################################### diff --git a/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/raise.py b/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/raise.py index db15be22e8d65..b656a97aa3f8c 100644 --- a/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/raise.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/raise.py @@ -66,20 +66,20 @@ raise ( ) # what now -raise ( # sould I stay here +raise ( # should I stay here # just a comment here ) # trailing comment -raise hello( # sould I stay here +raise hello( # should I stay here # just a comment here ) # trailing comment -raise ( # sould I stay here +raise ( # should I stay here test, # just a comment here ) # trailing comment -raise hello( # sould I stay here +raise hello( # should I stay here # just a comment here "hey" ) # trailing comment diff --git a/crates/ruff_python_formatter/src/comments/map.rs b/crates/ruff_python_formatter/src/comments/map.rs index 2e5846c85a410..c428dcc91caf5 100644 --- a/crates/ruff_python_formatter/src/comments/map.rs +++ b/crates/ruff_python_formatter/src/comments/map.rs @@ -16,7 +16,7 @@ use std::ops::Range; /// before inserting any parts for the key `b`. /// * The parts per key are inserted in the following order: *leading*, *dangling*, and then the *trailing* parts. /// -/// Parts inserted in the above mentioned order are stored in a `Vec` shared by all keys to reduce the number +/// Parts inserted in the above-mentioned order are stored in a `Vec` shared by all keys to reduce the number /// of allocations and increased cache locality. The implementation falls back to storing the *leading*, /// *dangling*, and *trailing* parts of a key in dedicated `Vec`s if the parts aren't inserted in the before mentioned order. /// Out of order insertions come with a slight performance penalty due to: diff --git a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__pep604_union_types_line_breaks.py.snap b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__pep604_union_types_line_breaks.py.snap index d84b08e5125c6..a0c99b1bffdc6 100644 --- a/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__pep604_union_types_line_breaks.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__pep604_union_types_line_breaks.py.snap @@ -26,7 +26,7 @@ z: (Short z: (int) = 2.3 z: ((int)) = foo() -# In case I go for not enforcing parantheses, this might get improved at the same time +# In case I go for not enforcing parentheses, this might get improved at the same time x = ( z == 9999999999999999999999999999999999999999 @@ -165,7 +165,7 @@ z: Short | Short2 | Short3 | Short4 = 8 z: int = 2.3 z: int = foo() -# In case I go for not enforcing parantheses, this might get improved at the same time +# In case I go for not enforcing parentheses, this might get improved at the same time x = ( z == 9999999999999999999999999999999999999999 @@ -269,7 +269,7 @@ z: Short | Short2 | Short3 | Short4 = 8 z: int = 2.3 z: int = foo() -# In case I go for not enforcing parantheses, this might get improved at the same time +# In case I go for not enforcing parentheses, this might get improved at the same time x = ( z == 9999999999999999999999999999999999999999 @@ -341,5 +341,3 @@ def f( another_option: bool = False, ): ... ``` - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap index d9091d1c90a41..5a9741d3b8516 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@docstring.py.snap @@ -154,7 +154,7 @@ class TabbedIndent: """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - author """ @@ -330,7 +330,7 @@ class TabbedIndent: """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - author """ @@ -506,7 +506,7 @@ class TabbedIndent: """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - author """ @@ -682,7 +682,7 @@ class TabbedIndent: """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - author """ @@ -858,7 +858,7 @@ class TabbedIndent: """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - author """ @@ -1034,7 +1034,7 @@ class TabbedIndent: """check for correct tabbed formatting ^^^^^^^^^^ Normal indented line - - autor + - author """ @@ -1042,6 +1042,3 @@ def single_quoted(): "content\ " return ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap index 2a0aa8fb0a711..2c8ff43b57cc8 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring.py.snap @@ -195,7 +195,7 @@ f"aaaaaa {[ yyyyyyyyyyyy ]} ccccccc" -# Remove the parenthese because they aren't required +# Remove the parentheses because they aren't required xxxxxxxxxxxxxxx = ( f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb { xxxxxxxxxxx # comment 14 @@ -220,7 +220,7 @@ f"{ # comment 15 # removed once we have a strict parser. x = f"aaaaaaaaa { x ! r }" -# Even in the case of debug expresions, we only need to preserve the whitespace within +# Even in the case of debug expressions, we only need to preserve the whitespace within # the expression part of the replacement field. x = f"aaaaaaaaa { x = ! r }" @@ -510,7 +510,7 @@ f"aaaaaa { ] } ccccccc" -# Remove the parenthese because they aren't required +# Remove the parentheses because they aren't required xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb { xxxxxxxxxxx # comment 14 + yyyyyyyyyy @@ -533,7 +533,7 @@ f"{ # comment 15 # removed once we have a strict parser. x = f"aaaaaaaaa {x!r}" -# Even in the case of debug expresions, we only need to preserve the whitespace within +# Even in the case of debug expressions, we only need to preserve the whitespace within # the expression part of the replacement field. x = f"aaaaaaaaa { x = !r}" @@ -804,7 +804,7 @@ f"aaaaaa {[ yyyyyyyyyyyy ]} ccccccc" -# Remove the parenthese because they aren't required +# Remove the parentheses because they aren't required xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb { xxxxxxxxxxx # comment 14 + yyyyyyyyyy @@ -827,7 +827,7 @@ f"{ # comment 15 # removed once we have a strict parser. x = f"aaaaaaaaa { x ! r }" -# Even in the case of debug expresions, we only need to preserve the whitespace within +# Even in the case of debug expressions, we only need to preserve the whitespace within # the expression part of the replacement field. x = f"aaaaaaaaa { x = ! r }" @@ -1086,7 +1086,7 @@ hello { + ] +} ccccccc" - # Remove the parenthese because they aren't required + # Remove the parentheses because they aren't required xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb { - xxxxxxxxxxx # comment 14 - + yyyyyyyyyy @@ -1113,7 +1113,7 @@ hello { -x = f"aaaaaaaaa { x ! r }" +x = f"aaaaaaaaa {x!r}" - # Even in the case of debug expresions, we only need to preserve the whitespace within + # Even in the case of debug expressions, we only need to preserve the whitespace within # the expression part of the replacement field. -x = f"aaaaaaaaa { x = ! r }" +x = f"aaaaaaaaa { x = !r}" @@ -1202,6 +1202,3 @@ hello { + } -------- """ ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap index 9377a83892af7..fd22501c96a68 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@expression__fstring_py312.py.snap @@ -8,7 +8,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression # the target version is 3.12 or later. A user can have 3.12 syntax even if the target # version isn't set. -# Quotes re-use +# Quotes reuse f"{'a'}" ``` @@ -33,7 +33,7 @@ source_type = Python # the target version is 3.12 or later. A user can have 3.12 syntax even if the target # version isn't set. -# Quotes re-use +# Quotes reuse f"{'a'}" ``` @@ -45,10 +45,7 @@ f"{'a'}" @@ -3,4 +3,4 @@ # version isn't set. - # Quotes re-use + # Quotes reuse -f"{'a'}" +f"{"a"}" ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap index 38ebe93bfea5c..f66b8bad7d6a7 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__no_fmt_on.py.snap @@ -11,7 +11,7 @@ def test(): if unformatted + a: pass -# Get's formatted again +# Gets formatted again a + b ``` @@ -25,9 +25,6 @@ def test(): pass -# Get's formatted again +# Gets formatted again a + b ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap index a8286e4691ed0..727884cef73e7 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__simple.py.snap @@ -4,29 +4,26 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off --- ## Input ```python -# Get's formatted +# Gets formatted a + b # fmt: off a + [1, 2, 3, 4, 5 ] # fmt: on -# Get's formatted again +# Gets formatted again a + b ``` ## Output ```python -# Get's formatted +# Gets formatted a + b # fmt: off a + [1, 2, 3, 4, 5 ] # fmt: on -# Get's formatted again +# Gets formatted again a + b ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap index 87940f270941b..7f3b39a0c4cae 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__yapf.py.snap @@ -4,14 +4,14 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off --- ## Input ```python -# Get's formatted +# Gets formatted a + b # yapf: disable a + [1, 2, 3, 4, 5 ] # yapf: enable -# Get's formatted again +# Gets formatted again a + b @@ -19,20 +19,20 @@ a + b a + [1, 2, 3, 4, 5 ] # fmt: on -# Get's formatted again +# Gets formatted again a + b ``` ## Output ```python -# Get's formatted +# Gets formatted a + b # yapf: disable a + [1, 2, 3, 4, 5 ] # yapf: enable -# Get's formatted again +# Gets formatted again a + b @@ -40,9 +40,6 @@ a + b a + [1, 2, 3, 4, 5 ] # fmt: on -# Get's formatted again +# Gets formatted again a + b ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__clause_header.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__clause_header.py.snap index 5a5f35cb61295..8238248983928 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__clause_header.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@range_formatting__clause_header.py.snap @@ -18,7 +18,7 @@ class Test(OtherClass)\ def __init__( self): print("hello") -print( "dont' format this") +print( "don't format this") def test2(a, b, c: str, d): @@ -65,7 +65,7 @@ class Test(OtherClass): # comment def __init__( self): print("hello") -print( "dont' format this") +print( "don't format this") def test2(a, b, c: str, d): @@ -96,6 +96,3 @@ if a + b: # trailing clause header comment if b + c: # trailing clause header comment print("Not formatted" ) ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap index ba00019351bf7..0bd2c2c1d141e 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__assignment_split_value_first.py.snap @@ -201,7 +201,7 @@ a[aaaaaaa, b] = ( cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment ) -# Format both as flat, but don't loos the comment. +# Format both as flat, but don't lose the comment. a[aaaaaaa, b] = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # comment ####################################################### @@ -455,7 +455,7 @@ a[aaaaaaa, b] = ( cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment ) -# Format both as flat, but don't loos the comment. +# Format both as flat, but don't lose the comment. a[aaaaaaa, b] = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # comment ####################################################### @@ -488,6 +488,3 @@ type A[ VeryLongTypeNameThatShouldBreakFirstToTheRightBeforeSplitngtinthatExceedsTheWidth ] = str ``` - - - diff --git a/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap b/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap index 3871a907f5f1e..0e5676f0b4c93 100644 --- a/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap +++ b/crates/ruff_python_formatter/tests/snapshots/format@statement__raise.py.snap @@ -72,20 +72,20 @@ raise ( # another comment raise ( ) # what now -raise ( # sould I stay here +raise ( # should I stay here # just a comment here ) # trailing comment -raise hello( # sould I stay here +raise hello( # should I stay here # just a comment here ) # trailing comment -raise ( # sould I stay here +raise ( # should I stay here test, # just a comment here ) # trailing comment -raise hello( # sould I stay here +raise hello( # should I stay here # just a comment here "hey" ) # trailing comment @@ -195,24 +195,21 @@ raise ( # another comment raise () # what now -raise ( # sould I stay here +raise ( # should I stay here # just a comment here ) # trailing comment -raise hello( # sould I stay here +raise hello( # should I stay here # just a comment here ) # trailing comment -raise ( # sould I stay here +raise ( # should I stay here test, # just a comment here ) # trailing comment -raise hello( # sould I stay here +raise hello( # should I stay here # just a comment here "hey" ) # trailing comment ``` - - - diff --git a/crates/ruff_python_parser/src/python.lalrpop b/crates/ruff_python_parser/src/python.lalrpop index 8480e9f4d77ce..c9708d9abba76 100644 --- a/crates/ruff_python_parser/src/python.lalrpop +++ b/crates/ruff_python_parser/src/python.lalrpop @@ -1936,7 +1936,7 @@ Comma: Vec = { } }; -/// One ore more items that are separated by a comma. +/// One or more items that are separated by a comma. OneOrMore: Vec = { => vec![e], > "," => { diff --git a/crates/ruff_python_parser/src/python.rs b/crates/ruff_python_parser/src/python.rs index f1fd0f33b093a..325fee5a1356b 100644 --- a/crates/ruff_python_parser/src/python.rs +++ b/crates/ruff_python_parser/src/python.rs @@ -1,5 +1,5 @@ // auto-generated: "lalrpop 0.20.0" -// sha3: b432b8de1a23821d6d810de35f61842d7d7a40634f366ea4db38b33140e657d5 +// sha3: c98876ae871e13c1a0cabf962138ded61584185a0c3144b626dac60f707ea396 use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_python_ast::{self as ast, Int, IpyEscapeKind}; use crate::{ diff --git a/crates/ruff_server/src/server/api.rs b/crates/ruff_server/src/server/api.rs index dd04997898405..a957ca24c42b8 100644 --- a/crates/ruff_server/src/server/api.rs +++ b/crates/ruff_server/src/server/api.rs @@ -12,8 +12,8 @@ use self::traits::{NotificationHandler, RequestHandler}; use super::{client::Responder, schedule::BackgroundSchedule, Result}; -/// Defines the `document_url` method for implementors of [`traits::Notification`] and [`traits::Request`], -/// given the parameter type used by the implementor. +/// Defines the `document_url` method for implementers of [`traits::Notification`] and [`traits::Request`], +/// given the parameter type used by the implementer. macro_rules! define_document_url { ($params:ident: &$p:ty) => { fn document_url($params: &$p) -> &lsp_types::Url { diff --git a/docs/formatter.md b/docs/formatter.md index 82f7a4b4a7127..df51389979ea1 100644 --- a/docs/formatter.md +++ b/docs/formatter.md @@ -289,7 +289,7 @@ def test(a, b, c, d, e, f) -> int: # fmt: skip pass ``` -As such, adding `# fmt: skip` comments at the end of an expressions will have no effect. In +As such, adding an `# fmt: skip` comment at the end of an expression will have no effect. In the following example, the list entry `'1'` will be formatted, despite the `# fmt: skip`: ```python diff --git a/docs/preview.md b/docs/preview.md index bae159690aa1a..bba1b5bd3e4e5 100644 --- a/docs/preview.md +++ b/docs/preview.md @@ -157,7 +157,7 @@ To see which rules are currently in preview, visit the [rules reference](rules.m ## Selecting single preview rules When preview mode is enabled, selecting rule categories or prefixes will include all preview rules that match. -If you'd prefer to opt-in to each preview rule individually, you can toggle the `explicit-preview-rules` +If you'd prefer to opt in to each preview rule individually, you can toggle the `explicit-preview-rules` setting in your configuration file: === "pyproject.toml" diff --git a/docs/versioning.md b/docs/versioning.md index 5d5414885d929..31de1e1b2e546 100644 --- a/docs/versioning.md +++ b/docs/versioning.md @@ -8,7 +8,7 @@ Ruff uses a custom versioning scheme that uses the **minor** version number for - A deprecated option or feature is removed - Configuration changes in a backwards incompatible way - - This _may_ occur in minor version changes until `1.0.0`, however it should generally be avoided. + - This _may_ occur in minor version changes until `1.0.0`, however, it should generally be avoided. - Support for a new file type is promoted to stable - Support for an end-of-life Python version is dropped - Linter: @@ -44,7 +44,7 @@ Ruff uses a custom versioning scheme that uses the **minor** version number for ## Preview mode -A preview mode is available to enable new, unstable rules and features e.g. support for a new file type. +A preview mode is available to enable new, unstable rules and features, e.g., support for a new file type. The preview mode is intended to help us collect community feedback and gain confidence that changes are a net-benefit. @@ -54,10 +54,10 @@ The preview mode is _not_ intended to gate access to work that is incomplete or When modifying or adding rules, we use the following guidelines: -- New rules are always be added in a preview mode -- New rules remain in preview mode for at least one minor release before being promoted to stable - - If added in a patch release i.e. `0.6.1` then a rule are not be eligible for stability until `0.8.0` -- Stable rule behavior are not changed significantly in patch versions +- New rules should always be added in preview mode +- New rules will remain in preview mode for at least one minor release before being promoted to stable + - If added in a patch release i.e. `0.6.1` then a rule will not be eligible for stability until `0.8.0` +- Stable rule behaviors are not changed significantly in patch versions - Promotion of rules to stable may be delayed in order to “batch” them into a single minor release - Not all rules in preview need to be promoted in a given minor release @@ -69,4 +69,4 @@ Fixes have three applicability levels: - **Unsafe**: Can be applied with explicit opt-in. - **Safe**: Can be applied automatically. -Fixes for rules may be introduced at a lower applicability then promoted to a higher applicability. Reducing the applicability of a fix is not a breaking change. The applicability of a given fix may change when the preview mode is enabled. +Fixes for rules may be introduced at a lower applicability, then promoted to a higher applicability. Reducing the applicability of a fix is not a breaking change. The applicability of a given fix may change when the preview mode is enabled.