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.
This commit is contained in:
Auguste Lalande 2024-03-12 22:34:23 -04:00 committed by GitHub
parent c56fb6e15a
commit 3ed707f245
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 135 additions and 170 deletions

View file

@ -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:

View file

@ -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.
///

View file

@ -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.")

View file

@ -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💣2ing.")

View file

@ -47,7 +47,7 @@ if (
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

View file

@ -48,7 +48,7 @@ __all__ = [
# 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__ = [

View file

@ -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

View file

@ -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.
///

View file

@ -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

View file

@ -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.
///

View file

@ -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.
///

View file

@ -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.

View file

@ -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.
///

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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.
///

View file

@ -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`

View file

@ -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. |

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.
///

View file

@ -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

View file

@ -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
|

View file

@ -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💣2ing.")
|
@ -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💣2ing."""
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|

View file

@ -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`

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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 | ):

View file

@ -92,7 +92,7 @@ pub fn derive_message_formats(_attr: TokenStream, item: TokenStream) -> TokenStr
///
/// Good:
///
/// ```ignroe
/// ```ignore
/// use ruff_macros::newtype_index;
///
/// #[newtype_index]

View file

@ -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
/// <https://github.com/psf/black/blob/69ca0a4c7a365c5f5eea519a90980bab72cab764/src/black/__init__.py#L1017-L1046>
@ -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" ");

View file

@ -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.

View file

@ -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.

View file

@ -19,7 +19,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

View file

@ -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

View file

@ -148,7 +148,7 @@ class TabbedIndent:
"""check for correct tabbed formatting
^^^^^^^^^^
Normal indented line
- autor
- author
"""

View file

@ -189,7 +189,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
@ -214,7 +214,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 }"

View file

@ -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'}"

View file

@ -5,5 +5,5 @@ def test():
if unformatted + a:
pass
# Get's formatted again
# Gets formatted again
a + b

View file

@ -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

View file

@ -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 + b
a + [1, 2, 3, 4, 5 ]
# fmt: on
# Get's formatted again
# Gets formatted again
a + b

View file

@ -12,7 +12,7 @@ class <RANGE_START> Test(OtherClass<RANGE_END>)\
def __init__( self):
print("hello")
print( "dont' format this")
print( "don't format this")
def test2(<RANGE_START>a, b, c: str, d):<RANGE_END>

View file

@ -195,7 +195,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
#######################################################

View file

@ -66,20 +66,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

View file

@ -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:

View file

@ -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,
): ...
```

View file

@ -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
```

View file

@ -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 {
+ } --------
"""
```

View file

@ -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"}"
```

View file

@ -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
```

View file

@ -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
```

View file

@ -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
```

View file

@ -18,7 +18,7 @@ class <RANGE_START> Test(OtherClass<RANGE_END>)\
def __init__( self):
print("hello")
print( "dont' format this")
print( "don't format this")
def test2(<RANGE_START>a, b, c: str, d):<RANGE_END>
@ -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" )
```

View file

@ -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
```

View file

@ -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
```

View file

@ -1936,7 +1936,7 @@ Comma<T>: Vec<T> = {
}
};
/// One ore more items that are separated by a comma.
/// One or more items that are separated by a comma.
OneOrMore<T>: Vec<T> = {
<e:T> => vec![e],
<mut v: OneOrMore<T>> "," <e:T> => {

View file

@ -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::{

View file

@ -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 {

View file

@ -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

View file

@ -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"

View file

@ -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.