mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:23:11 +00:00
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:
parent
c56fb6e15a
commit
3ed707f245
67 changed files with 135 additions and 170 deletions
|
@ -23,7 +23,7 @@ fn default_options() {
|
||||||
.arg("-")
|
.arg("-")
|
||||||
.pass_stdin(r#"
|
.pass_stdin(r#"
|
||||||
def foo(arg1, arg2,):
|
def foo(arg1, arg2,):
|
||||||
print('Should\'t change quotes')
|
print('Shouldn\'t change quotes')
|
||||||
|
|
||||||
|
|
||||||
if condition:
|
if condition:
|
||||||
|
@ -38,7 +38,7 @@ if condition:
|
||||||
arg1,
|
arg1,
|
||||||
arg2,
|
arg2,
|
||||||
):
|
):
|
||||||
print("Should't change quotes")
|
print("Shouldn't change quotes")
|
||||||
|
|
||||||
|
|
||||||
if condition:
|
if condition:
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub trait Buffer {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn elements(&self) -> &[FormatElement];
|
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.
|
/// This method should generally not be invoked manually, but rather through the [`write!`] macro itself.
|
||||||
///
|
///
|
||||||
|
|
|
@ -10,7 +10,7 @@ def f1():
|
||||||
# Here's a standalone comment that's over the limit.
|
# Here's a standalone comment that's over the limit.
|
||||||
|
|
||||||
x = 2
|
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.")
|
print("Here's a string that's over the limit, but it's not a docstring.")
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ def f1():
|
||||||
# Here's a standalone comment that's over theß9💣2ℝ.
|
# Here's a standalone comment that's over theß9💣2ℝ.
|
||||||
|
|
||||||
x = 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.")
|
print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.")
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ if (
|
||||||
and some_third_reasonably_long_condition
|
and some_third_reasonably_long_condition
|
||||||
or some_fourth_reasonably_long_condition
|
or some_fourth_reasonably_long_condition
|
||||||
and some_fifth_reasonably_long_condition
|
and some_fifth_reasonably_long_condition
|
||||||
# a commment
|
# a comment
|
||||||
and some_sixth_reasonably_long_condition
|
and some_sixth_reasonably_long_condition
|
||||||
and some_seventh_reasonably_long_condition
|
and some_seventh_reasonably_long_condition
|
||||||
# another comment
|
# another comment
|
||||||
|
|
|
@ -48,7 +48,7 @@ __all__ = [
|
||||||
# we implement an "isort-style sort":
|
# we implement an "isort-style sort":
|
||||||
# SCEAMING_CASE constants first,
|
# SCEAMING_CASE constants first,
|
||||||
# then CamelCase classes,
|
# then CamelCase classes,
|
||||||
# then anything thats lowercase_snake_case.
|
# then anything that's lowercase_snake_case.
|
||||||
# This (which is currently alphabetically sorted)
|
# This (which is currently alphabetically sorted)
|
||||||
# should get reordered accordingly:
|
# should get reordered accordingly:
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|
|
@ -294,7 +294,7 @@ impl Violation for MissingReturnTypePrivateFunction {
|
||||||
///
|
///
|
||||||
/// Note that type checkers often allow you to omit the return type annotation for
|
/// 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
|
/// `__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:
|
/// or `ruff.toml` file:
|
||||||
///
|
///
|
||||||
/// ```toml
|
/// ```toml
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// `logging.config.listen` starts a server that listens for logging
|
/// `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
|
/// passed to the built-in `eval` function, which can be used to execute
|
||||||
/// arbitrary code.
|
/// arbitrary code.
|
||||||
///
|
///
|
||||||
|
|
|
@ -222,7 +222,7 @@ impl Violation for StartProcessWithNoShell {
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Starting a process with a partial executable path can allow attackers to
|
/// 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.
|
/// Consider using a full path to the executable instead.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// Checks for uses of policies disabling SSH verification in Paramiko.
|
/// Checks for uses of policies disabling SSH verification in Paramiko.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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
|
/// an SSH connection. Disabling the verification might lead to the client
|
||||||
/// connecting to a malicious host, without the client knowing.
|
/// connecting to a malicious host, without the client knowing.
|
||||||
///
|
///
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl Violation for SuspiciousPickleUsage {
|
||||||
/// Checks for calls to `marshal` functions.
|
/// Checks for calls to `marshal` functions.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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
|
/// the creation of arbitrary objects, which can then be used to achieve
|
||||||
/// arbitrary code execution and otherwise unexpected behavior.
|
/// 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
|
/// If you must deserialize untrusted data with `marshal`, consider signing the
|
||||||
/// data with a secret key and verifying the signature before deserializing 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.
|
/// into the serialized data.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
@ -353,7 +353,7 @@ impl Violation for SuspiciousMarkSafeUsage {
|
||||||
/// behavior.
|
/// behavior.
|
||||||
///
|
///
|
||||||
/// To mitigate this risk, audit all uses of URL open functions and ensure that
|
/// 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:`).
|
/// disallowing `file:` and `ftp:`).
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
@ -395,7 +395,7 @@ impl Violation for SuspiciousURLOpenUsage {
|
||||||
/// Checks for uses of cryptographically weak pseudo-random number generators.
|
/// Checks for uses of cryptographically weak pseudo-random number generators.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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
|
/// are easily predictable. This can allow an attacker to guess the generated
|
||||||
/// numbers and compromise the security of the system.
|
/// numbers and compromise the security of the system.
|
||||||
///
|
///
|
||||||
|
|
|
@ -245,7 +245,7 @@ impl Violation for SuspiciousLxmlImport {
|
||||||
/// Checks for imports of the `xmlrpc` module.
|
/// Checks for imports of the `xmlrpc` module.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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()`
|
/// communicating data over a network. Use the `defused.xmlrpc.monkey_patch()`
|
||||||
/// function to monkey-patch the `xmlrpclib` module and mitigate remote XML
|
/// function to monkey-patch the `xmlrpclib` module and mitigate remote XML
|
||||||
/// attacks.
|
/// attacks.
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::rules::flake8_comprehensions::settings::Settings;
|
||||||
/// rewritten as empty literals.
|
/// rewritten as empty literals.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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
|
/// literal (`{}`). The former is slower because the name `dict` must be
|
||||||
/// looked up in the global scope in case it has been rebound.
|
/// looked up in the global scope in case it has been rebound.
|
||||||
///
|
///
|
||||||
|
|
|
@ -10,14 +10,14 @@ use crate::checkers::ast::Checker;
|
||||||
use super::helpers;
|
use super::helpers;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## 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?
|
/// ## 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
|
/// of the model instance, as Django calls this method to display the object in
|
||||||
/// the Django Admin and elsewhere.
|
/// 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.
|
/// of the object in the Django Admin.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// The `startswith` and `endswith` methods accept tuples of prefixes or
|
/// The `startswith` and `endswith` methods accept tuples of prefixes or
|
||||||
/// suffixes respectively. Passing a tuple of prefixes or suffixes is more
|
/// 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
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// Checks for the presence of multiple literal types in a union.
|
/// Checks for the presence of multiple literal types in a union.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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.
|
/// as a single literal.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -103,9 +103,9 @@ impl Violation for PytestParametrizeNamesWrongType {
|
||||||
/// of values.
|
/// of values.
|
||||||
///
|
///
|
||||||
/// The style for the list of values rows can be configured via the
|
/// 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
|
/// 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
|
/// For example, [`lint.flake8-pytest-style.parametrize-values-type`] will lead to
|
||||||
/// the following expectations:
|
/// the following expectations:
|
||||||
|
|
|
@ -151,7 +151,7 @@ impl AlwaysFixableViolation for ImplicitReturn {
|
||||||
/// assigned variable.
|
/// assigned variable.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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.
|
/// directly.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl Violation for IfExprWithTrueFalse {
|
||||||
/// condition.
|
/// condition.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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
|
/// for a falsey condition can be replaced with `not` operators, which are more
|
||||||
/// concise and readable.
|
/// concise and readable.
|
||||||
///
|
///
|
||||||
|
|
|
@ -13,15 +13,14 @@ use crate::rules::flake8_tidy_imports::matchers::NameMatchPolicy;
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Projects may want to ensure that specific modules or module members are
|
/// 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
|
/// Security or other company policies may be a reason to impose
|
||||||
/// restrictions on importing external Python libraries. In some cases,
|
/// restrictions on importing external Python libraries. In some cases,
|
||||||
/// projects may adopt conventions around the use of certain modules or
|
/// projects may adopt conventions around the use of certain modules or
|
||||||
/// module members that are not enforceable by the language itself.
|
/// module members that are not enforceable by the language itself.
|
||||||
///
|
///
|
||||||
/// This rule enforces certain import conventions project-wide in an
|
/// This rule enforces certain import conventions project-wide automatically.
|
||||||
/// automatic way.
|
|
||||||
///
|
///
|
||||||
/// ## Options
|
/// ## Options
|
||||||
/// - `lint.flake8-tidy-imports.banned-api`
|
/// - `lint.flake8-tidy-imports.banned-api`
|
||||||
|
|
|
@ -16,7 +16,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||||
///
|
///
|
||||||
/// | | `glob` | `Path.glob` |
|
/// | | `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. |
|
/// | 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. |
|
/// | 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. |
|
/// | 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. |
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// primarily for historic reasons, and have been a cause of
|
/// primarily for historic reasons, and have been a cause of
|
||||||
/// frequent confusion for newcomers.
|
/// 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
|
/// ## Examples
|
||||||
/// ```python
|
/// ```python
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::rules::pandas_vet::helpers::{test_expression, Resolution};
|
||||||
/// Checks for uses of `.values` on Pandas Series and Index objects.
|
/// Checks for uses of `.values` on Pandas Series and Index objects.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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.
|
/// such, it is no longer recommended by the Pandas documentation.
|
||||||
///
|
///
|
||||||
/// Instead, use `.to_numpy()` to return a NumPy array, or `.array` to return a
|
/// Instead, use `.to_numpy()` to return a NumPy array, or `.array` to return a
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::rules::pep8_naming::settings::IgnoreNames;
|
||||||
/// > all-lowercase names, although the use of underscores is discouraged.
|
/// > 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
|
/// > 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`).
|
/// > a leading underscore (e.g. `_socket`).
|
||||||
///
|
///
|
||||||
/// Further, in order for Python modules to be importable, they must be valid
|
/// Further, in order for Python modules to be importable, they must be valid
|
||||||
|
|
|
@ -241,7 +241,7 @@ impl AlwaysFixableViolation for BlankLineAfterDecorator {
|
||||||
/// Checks for missing blank lines after the end of function or class.
|
/// Checks for missing blank lines after the end of function or class.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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
|
/// - Two blank lines are expected between functions and classes
|
||||||
/// - One blank line is expected between methods of a class.
|
/// - 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.
|
/// Checks for 1 blank line between nested function or class definitions.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## 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
|
/// - Two blank lines are expected between functions and classes
|
||||||
/// - One blank line is expected between methods of a class.
|
/// - One blank line is expected between methods of a class.
|
||||||
///
|
///
|
||||||
|
|
|
@ -9,8 +9,9 @@ use ruff_source_file::Locator;
|
||||||
/// Checks for files missing a new line at the end of the file.
|
/// Checks for files missing a new line at the end of the file.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Trailing blank lines are superfluous.
|
/// Trailing blank lines in a file are superfluous.
|
||||||
/// However the last line should end with a new line.
|
///
|
||||||
|
/// However, the last line of the file should end with a newline.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
|
|
@ -27,11 +27,11 @@ W505.py:10:51: W505 Doc line too long (56 > 50)
|
||||||
12 | x = 2
|
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
|
12 | x = 2
|
||||||
13 | # Another standalone that is preceded by a newline and indent toke and is over the limit.
|
13 | # Another standalone that is preceded by a newline and indent token and is over the limit.
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
||||||
14 |
|
14 |
|
||||||
15 | print("Here's a string that's over the limit, but it's not a docstring.")
|
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."""
|
31 | It's over the limit on this line, which isn't the first line in the docstring."""
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,11 @@ W505_utf_8.py:10:51: W505 Doc line too long (56 > 50)
|
||||||
12 | x = 2
|
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
|
12 | x = 2
|
||||||
13 | # Another standalone that is preceded by a newline and indent toke and is over theß9💣2ℝ.
|
13 | # Another standalone that is preceded by a newline and indent token and is over theß9💣2ℝ.
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
||||||
14 |
|
14 |
|
||||||
15 | print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.")
|
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."""
|
31 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing."""
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl AlwaysFixableViolation for OneBlankLineBeforeClass {
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// [PEP 257] recommends the use of a blank line to separate a class's
|
/// [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
|
/// 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`
|
/// convention. By default, this rule is enabled when using the `google`
|
||||||
|
|
|
@ -368,7 +368,7 @@ impl Violation for UndocumentedPublicPackage {
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Magic methods (methods with names that start and end with double
|
/// Magic methods (methods with names that start and end with double
|
||||||
/// underscores) are used to implement operator overloading and other special
|
/// 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.
|
/// outline their behavior.
|
||||||
///
|
///
|
||||||
/// Generally, magic method docstrings should describe the method's behavior,
|
/// Generally, magic method docstrings should describe the method's behavior,
|
||||||
|
|
|
@ -13,8 +13,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// An empty string is falsy, so it is unnecessary to compare it to `""`. If
|
/// 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
|
/// the value can be something else Python considers falsy, such as `None`,
|
||||||
/// `0` or another empty container, then the code is not equivalent.
|
/// `0`, or another empty container, then the code is not equivalent.
|
||||||
///
|
///
|
||||||
/// ## Known problems
|
/// ## Known problems
|
||||||
/// High false positive rate, as the check is context-insensitive and does not
|
/// High false positive rate, as the check is context-insensitive and does not
|
||||||
|
|
|
@ -6,8 +6,8 @@ use ruff_macros::{derive_message_formats, violation};
|
||||||
/// that redefine function parameters.
|
/// that redefine function parameters.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Redefined variable can cause unexpected behavior because of overridden function parameter.
|
/// Redefined variables can cause unexpected behavior because of overridden function parameters.
|
||||||
/// If nested functions are declared, inner function's body can override outer function's parameter.
|
/// If nested functions are declared, an inner function's body can override an outer function's parameters.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
|
|
@ -29,7 +29,7 @@ use crate::checkers::ast::Checker;
|
||||||
/// into the remainder of the enclosing loop.
|
/// into the remainder of the enclosing loop.
|
||||||
///
|
///
|
||||||
/// While this mistake is easy to spot in small examples, it can be hidden
|
/// 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.
|
/// variable may not be visible at the same time.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -43,7 +43,7 @@ use crate::fix::snippet::SourceCodeSnippet;
|
||||||
/// This rule's fix is marked as unsafe, as migrating from (e.g.) `list(...)[0]`
|
/// 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:
|
/// 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
|
/// collection, while `next(iter(...))` will only evaluate the first
|
||||||
/// element. As such, any side effects that occur during iteration will be
|
/// element. As such, any side effects that occur during iteration will be
|
||||||
/// delayed.
|
/// delayed.
|
||||||
|
|
|
@ -223,7 +223,7 @@ RUF021.py:46:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and
|
||||||
47 |+ and some_third_reasonably_long_condition)
|
47 |+ and some_third_reasonably_long_condition)
|
||||||
48 48 | or some_fourth_reasonably_long_condition
|
48 48 | or some_fourth_reasonably_long_condition
|
||||||
49 49 | and some_fifth_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
|
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
|
48 | or some_fourth_reasonably_long_condition
|
||||||
| ________^
|
| ________^
|
||||||
49 | | and some_fifth_reasonably_long_condition
|
49 | | and some_fifth_reasonably_long_condition
|
||||||
50 | | # a commment
|
50 | | # a comment
|
||||||
51 | | and some_sixth_reasonably_long_condition
|
51 | | and some_sixth_reasonably_long_condition
|
||||||
52 | | and some_seventh_reasonably_long_condition
|
52 | | and some_seventh_reasonably_long_condition
|
||||||
| |______________________________________________^ RUF021
|
| |______________________________________________^ 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
|
||||||
48 |+ or (some_fourth_reasonably_long_condition
|
48 |+ or (some_fourth_reasonably_long_condition
|
||||||
49 49 | and some_fifth_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
|
51 51 | and some_sixth_reasonably_long_condition
|
||||||
52 |- and some_seventh_reasonably_long_condition
|
52 |- and some_seventh_reasonably_long_condition
|
||||||
52 |+ and some_seventh_reasonably_long_condition)
|
52 |+ and some_seventh_reasonably_long_condition)
|
||||||
53 53 | # another comment
|
53 53 | # another comment
|
||||||
54 54 | or some_eighth_reasonably_long_condition
|
54 54 | or some_eighth_reasonably_long_condition
|
||||||
55 55 | ):
|
55 55 | ):
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ pub fn derive_message_formats(_attr: TokenStream, item: TokenStream) -> TokenStr
|
||||||
///
|
///
|
||||||
/// Good:
|
/// Good:
|
||||||
///
|
///
|
||||||
/// ```ignroe
|
/// ```ignore
|
||||||
/// use ruff_macros::newtype_index;
|
/// use ruff_macros::newtype_index;
|
||||||
///
|
///
|
||||||
/// #[newtype_index]
|
/// #[newtype_index]
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl Notebook {
|
||||||
Self::from_reader(Cursor::new(source_code))
|
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
|
/// See also the black implementation
|
||||||
/// <https://github.com/psf/black/blob/69ca0a4c7a365c5f5eea519a90980bab72cab764/src/black/__init__.py#L1017-L1046>
|
/// <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")
|
.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> {
|
pub fn write(&self, writer: &mut dyn Write) -> Result<(), NotebookError> {
|
||||||
// https://github.com/psf/black/blob/69ca0a4c7a365c5f5eea519a90980bab72cab764/src/black/__init__.py#LL1041
|
// https://github.com/psf/black/blob/69ca0a4c7a365c5f5eea519a90980bab72cab764/src/black/__init__.py#LL1041
|
||||||
let formatter = serde_json::ser::PrettyFormatter::with_indent(b" ");
|
let formatter = serde_json::ser::PrettyFormatter::with_indent(b" ");
|
||||||
|
|
|
@ -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 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
|
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:
|
if True:
|
||||||
# Incorrectly indented prefix comments.
|
# Incorrectly indented prefix comments.
|
||||||
|
|
|
@ -28,7 +28,7 @@ def foo3(
|
||||||
|
|
||||||
def foo4(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:
|
if True:
|
||||||
# Incorrectly indented prefix comments.
|
# Incorrectly indented prefix comments.
|
||||||
|
|
|
@ -19,7 +19,7 @@ z: (Short
|
||||||
z: (int) = 2.3
|
z: (int) = 2.3
|
||||||
z: ((int)) = foo()
|
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 = (
|
x = (
|
||||||
z
|
z
|
||||||
== 9999999999999999999999999999999999999999
|
== 9999999999999999999999999999999999999999
|
||||||
|
|
|
@ -28,7 +28,7 @@ z: Short | Short2 | Short3 | Short4 = 8
|
||||||
z: int = 2.3
|
z: int = 2.3
|
||||||
z: int = foo()
|
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 = (
|
x = (
|
||||||
z
|
z
|
||||||
== 9999999999999999999999999999999999999999
|
== 9999999999999999999999999999999999999999
|
||||||
|
|
|
@ -148,7 +148,7 @@ class TabbedIndent:
|
||||||
"""check for correct tabbed formatting
|
"""check for correct tabbed formatting
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
Normal indented line
|
Normal indented line
|
||||||
- autor
|
- author
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ f"aaaaaa {[
|
||||||
yyyyyyyyyyyy
|
yyyyyyyyyyyy
|
||||||
]} ccccccc"
|
]} ccccccc"
|
||||||
|
|
||||||
# Remove the parenthese because they aren't required
|
# Remove the parentheses because they aren't required
|
||||||
xxxxxxxxxxxxxxx = (
|
xxxxxxxxxxxxxxx = (
|
||||||
f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
||||||
xxxxxxxxxxx # comment 14
|
xxxxxxxxxxx # comment 14
|
||||||
|
@ -214,7 +214,7 @@ f"{ # comment 15
|
||||||
# removed once we have a strict parser.
|
# removed once we have a strict parser.
|
||||||
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.
|
# the expression part of the replacement field.
|
||||||
x = f"aaaaaaaaa { x = ! r }"
|
x = f"aaaaaaaaa { x = ! r }"
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
# the target version is 3.12 or later. A user can have 3.12 syntax even if the target
|
# the target version is 3.12 or later. A user can have 3.12 syntax even if the target
|
||||||
# version isn't set.
|
# version isn't set.
|
||||||
|
|
||||||
# Quotes re-use
|
# Quotes reuse
|
||||||
f"{'a'}"
|
f"{'a'}"
|
||||||
|
|
|
@ -5,5 +5,5 @@ def test():
|
||||||
if unformatted + a:
|
if unformatted + a:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Get's formatted
|
# Gets formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# Get's formatted
|
# Gets formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
# yapf: disable
|
# yapf: disable
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# yapf: enable
|
# yapf: enable
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,5 +13,5 @@ a + b
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
|
|
|
@ -12,7 +12,7 @@ class <RANGE_START> Test(OtherClass<RANGE_END>)\
|
||||||
def __init__( self):
|
def __init__( self):
|
||||||
print("hello")
|
print("hello")
|
||||||
|
|
||||||
print( "dont' format this")
|
print( "don't format this")
|
||||||
|
|
||||||
|
|
||||||
def test2(<RANGE_START>a, b, c: str, d):<RANGE_END>
|
def test2(<RANGE_START>a, b, c: str, d):<RANGE_END>
|
||||||
|
|
|
@ -195,7 +195,7 @@ a[aaaaaaa, b] = (
|
||||||
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment
|
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
|
a[aaaaaaa, b] = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # comment
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
|
|
|
@ -66,20 +66,20 @@ raise ( # another comment
|
||||||
raise (
|
raise (
|
||||||
) # what now
|
) # what now
|
||||||
|
|
||||||
raise ( # sould I stay here
|
raise ( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise hello( # sould I stay here
|
raise hello( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise ( # sould I stay here
|
raise ( # should I stay here
|
||||||
test,
|
test,
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise hello( # sould I stay here
|
raise hello( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
"hey"
|
"hey"
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::ops::Range;
|
||||||
/// before inserting any parts for the key `b`.
|
/// 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.
|
/// * 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*,
|
/// 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.
|
/// *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:
|
/// Out of order insertions come with a slight performance penalty due to:
|
||||||
|
|
|
@ -26,7 +26,7 @@ z: (Short
|
||||||
z: (int) = 2.3
|
z: (int) = 2.3
|
||||||
z: ((int)) = foo()
|
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 = (
|
x = (
|
||||||
z
|
z
|
||||||
== 9999999999999999999999999999999999999999
|
== 9999999999999999999999999999999999999999
|
||||||
|
@ -165,7 +165,7 @@ z: Short | Short2 | Short3 | Short4 = 8
|
||||||
z: int = 2.3
|
z: int = 2.3
|
||||||
z: int = foo()
|
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 = (
|
x = (
|
||||||
z
|
z
|
||||||
== 9999999999999999999999999999999999999999
|
== 9999999999999999999999999999999999999999
|
||||||
|
@ -269,7 +269,7 @@ z: Short | Short2 | Short3 | Short4 = 8
|
||||||
z: int = 2.3
|
z: int = 2.3
|
||||||
z: int = foo()
|
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 = (
|
x = (
|
||||||
z
|
z
|
||||||
== 9999999999999999999999999999999999999999
|
== 9999999999999999999999999999999999999999
|
||||||
|
@ -341,5 +341,3 @@ def f(
|
||||||
another_option: bool = False,
|
another_option: bool = False,
|
||||||
): ...
|
): ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ class TabbedIndent:
|
||||||
"""check for correct tabbed formatting
|
"""check for correct tabbed formatting
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
Normal indented line
|
Normal indented line
|
||||||
- autor
|
- author
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ class TabbedIndent:
|
||||||
"""check for correct tabbed formatting
|
"""check for correct tabbed formatting
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
Normal indented line
|
Normal indented line
|
||||||
- autor
|
- author
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ class TabbedIndent:
|
||||||
"""check for correct tabbed formatting
|
"""check for correct tabbed formatting
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
Normal indented line
|
Normal indented line
|
||||||
- autor
|
- author
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ class TabbedIndent:
|
||||||
"""check for correct tabbed formatting
|
"""check for correct tabbed formatting
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
Normal indented line
|
Normal indented line
|
||||||
- autor
|
- author
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -858,7 +858,7 @@ class TabbedIndent:
|
||||||
"""check for correct tabbed formatting
|
"""check for correct tabbed formatting
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
Normal indented line
|
Normal indented line
|
||||||
- autor
|
- author
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -1034,7 +1034,7 @@ class TabbedIndent:
|
||||||
"""check for correct tabbed formatting
|
"""check for correct tabbed formatting
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
Normal indented line
|
Normal indented line
|
||||||
- autor
|
- author
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -1042,6 +1042,3 @@ def single_quoted():
|
||||||
"content\ "
|
"content\ "
|
||||||
return
|
return
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ f"aaaaaa {[
|
||||||
yyyyyyyyyyyy
|
yyyyyyyyyyyy
|
||||||
]} ccccccc"
|
]} ccccccc"
|
||||||
|
|
||||||
# Remove the parenthese because they aren't required
|
# Remove the parentheses because they aren't required
|
||||||
xxxxxxxxxxxxxxx = (
|
xxxxxxxxxxxxxxx = (
|
||||||
f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
||||||
xxxxxxxxxxx # comment 14
|
xxxxxxxxxxx # comment 14
|
||||||
|
@ -220,7 +220,7 @@ f"{ # comment 15
|
||||||
# removed once we have a strict parser.
|
# removed once we have a strict parser.
|
||||||
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.
|
# the expression part of the replacement field.
|
||||||
x = f"aaaaaaaaa { x = ! r }"
|
x = f"aaaaaaaaa { x = ! r }"
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ f"aaaaaa {
|
||||||
]
|
]
|
||||||
} ccccccc"
|
} ccccccc"
|
||||||
|
|
||||||
# Remove the parenthese because they aren't required
|
# Remove the parentheses because they aren't required
|
||||||
xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
||||||
xxxxxxxxxxx # comment 14
|
xxxxxxxxxxx # comment 14
|
||||||
+ yyyyyyyyyy
|
+ yyyyyyyyyy
|
||||||
|
@ -533,7 +533,7 @@ f"{ # comment 15
|
||||||
# removed once we have a strict parser.
|
# removed once we have a strict parser.
|
||||||
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.
|
# the expression part of the replacement field.
|
||||||
x = f"aaaaaaaaa { x = !r}"
|
x = f"aaaaaaaaa { x = !r}"
|
||||||
|
|
||||||
|
@ -804,7 +804,7 @@ f"aaaaaa {[
|
||||||
yyyyyyyyyyyy
|
yyyyyyyyyyyy
|
||||||
]} ccccccc"
|
]} ccccccc"
|
||||||
|
|
||||||
# Remove the parenthese because they aren't required
|
# Remove the parentheses because they aren't required
|
||||||
xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
||||||
xxxxxxxxxxx # comment 14
|
xxxxxxxxxxx # comment 14
|
||||||
+ yyyyyyyyyy
|
+ yyyyyyyyyy
|
||||||
|
@ -827,7 +827,7 @@ f"{ # comment 15
|
||||||
# removed once we have a strict parser.
|
# removed once we have a strict parser.
|
||||||
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.
|
# the expression part of the replacement field.
|
||||||
x = f"aaaaaaaaa { x = ! r }"
|
x = f"aaaaaaaaa { x = ! r }"
|
||||||
|
|
||||||
|
@ -1086,7 +1086,7 @@ hello {
|
||||||
+ ]
|
+ ]
|
||||||
+} ccccccc"
|
+} ccccccc"
|
||||||
|
|
||||||
# Remove the parenthese because they aren't required
|
# Remove the parentheses because they aren't required
|
||||||
xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
xxxxxxxxxxxxxxx = f"aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbb {
|
||||||
- xxxxxxxxxxx # comment 14
|
- xxxxxxxxxxx # comment 14
|
||||||
- + yyyyyyyyyy
|
- + yyyyyyyyyy
|
||||||
|
@ -1113,7 +1113,7 @@ hello {
|
||||||
-x = f"aaaaaaaaa { x ! r }"
|
-x = f"aaaaaaaaa { x ! r }"
|
||||||
+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.
|
# the expression part of the replacement field.
|
||||||
-x = f"aaaaaaaaa { x = ! r }"
|
-x = f"aaaaaaaaa { x = ! r }"
|
||||||
+x = f"aaaaaaaaa { x = !r}"
|
+x = f"aaaaaaaaa { x = !r}"
|
||||||
|
@ -1202,6 +1202,3 @@ hello {
|
||||||
+ } --------
|
+ } --------
|
||||||
"""
|
"""
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
# the target version is 3.12 or later. A user can have 3.12 syntax even if the target
|
||||||
# version isn't set.
|
# version isn't set.
|
||||||
|
|
||||||
# Quotes re-use
|
# Quotes reuse
|
||||||
f"{'a'}"
|
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
|
# the target version is 3.12 or later. A user can have 3.12 syntax even if the target
|
||||||
# version isn't set.
|
# version isn't set.
|
||||||
|
|
||||||
# Quotes re-use
|
# Quotes reuse
|
||||||
f"{'a'}"
|
f"{'a'}"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -45,10 +45,7 @@ f"{'a'}"
|
||||||
@@ -3,4 +3,4 @@
|
@@ -3,4 +3,4 @@
|
||||||
# version isn't set.
|
# version isn't set.
|
||||||
|
|
||||||
# Quotes re-use
|
# Quotes reuse
|
||||||
-f"{'a'}"
|
-f"{'a'}"
|
||||||
+f"{"a"}"
|
+f"{"a"}"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ def test():
|
||||||
if unformatted + a:
|
if unformatted + a:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -25,9 +25,6 @@ def test():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,29 +4,26 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```python
|
```python
|
||||||
# Get's formatted
|
# Gets formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```python
|
```python
|
||||||
# Get's formatted
|
# Gets formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```python
|
```python
|
||||||
# Get's formatted
|
# Gets formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
# yapf: disable
|
# yapf: disable
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# yapf: enable
|
# yapf: enable
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,20 +19,20 @@ a + b
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```python
|
```python
|
||||||
# Get's formatted
|
# Gets formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
# yapf: disable
|
# yapf: disable
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# yapf: enable
|
# yapf: enable
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,9 +40,6 @@ a + b
|
||||||
a + [1, 2, 3, 4, 5 ]
|
a + [1, 2, 3, 4, 5 ]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
# Get's formatted again
|
# Gets formatted again
|
||||||
a + b
|
a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class <RANGE_START> Test(OtherClass<RANGE_END>)\
|
||||||
def __init__( self):
|
def __init__( self):
|
||||||
print("hello")
|
print("hello")
|
||||||
|
|
||||||
print( "dont' format this")
|
print( "don't format this")
|
||||||
|
|
||||||
|
|
||||||
def test2(<RANGE_START>a, b, c: str, d):<RANGE_END>
|
def test2(<RANGE_START>a, b, c: str, d):<RANGE_END>
|
||||||
|
@ -65,7 +65,7 @@ class Test(OtherClass): # comment
|
||||||
def __init__( self):
|
def __init__( self):
|
||||||
print("hello")
|
print("hello")
|
||||||
|
|
||||||
print( "dont' format this")
|
print( "don't format this")
|
||||||
|
|
||||||
|
|
||||||
def test2(a, b, c: str, d):
|
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
|
if b + c: # trailing clause header comment
|
||||||
print("Not formatted" )
|
print("Not formatted" )
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ a[aaaaaaa, b] = (
|
||||||
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment
|
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
|
a[aaaaaaa, b] = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # comment
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
|
@ -455,7 +455,7 @@ a[aaaaaaa, b] = (
|
||||||
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc # comment
|
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
|
a[aaaaaaa, b] = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # comment
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
|
@ -488,6 +488,3 @@ type A[
|
||||||
VeryLongTypeNameThatShouldBreakFirstToTheRightBeforeSplitngtinthatExceedsTheWidth
|
VeryLongTypeNameThatShouldBreakFirstToTheRightBeforeSplitngtinthatExceedsTheWidth
|
||||||
] = str
|
] = str
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,20 +72,20 @@ raise ( # another comment
|
||||||
raise (
|
raise (
|
||||||
) # what now
|
) # what now
|
||||||
|
|
||||||
raise ( # sould I stay here
|
raise ( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise hello( # sould I stay here
|
raise hello( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise ( # sould I stay here
|
raise ( # should I stay here
|
||||||
test,
|
test,
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise hello( # sould I stay here
|
raise hello( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
"hey"
|
"hey"
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
@ -195,24 +195,21 @@ raise ( # another comment
|
||||||
|
|
||||||
raise () # what now
|
raise () # what now
|
||||||
|
|
||||||
raise ( # sould I stay here
|
raise ( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise hello( # sould I stay here
|
raise hello( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise ( # sould I stay here
|
raise ( # should I stay here
|
||||||
test,
|
test,
|
||||||
# just a comment here
|
# just a comment here
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
|
|
||||||
raise hello( # sould I stay here
|
raise hello( # should I stay here
|
||||||
# just a comment here
|
# just a comment here
|
||||||
"hey"
|
"hey"
|
||||||
) # trailing comment
|
) # trailing comment
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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> = {
|
OneOrMore<T>: Vec<T> = {
|
||||||
<e:T> => vec![e],
|
<e:T> => vec![e],
|
||||||
<mut v: OneOrMore<T>> "," <e:T> => {
|
<mut v: OneOrMore<T>> "," <e:T> => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// auto-generated: "lalrpop 0.20.0"
|
// auto-generated: "lalrpop 0.20.0"
|
||||||
// sha3: b432b8de1a23821d6d810de35f61842d7d7a40634f366ea4db38b33140e657d5
|
// sha3: c98876ae871e13c1a0cabf962138ded61584185a0c3144b626dac60f707ea396
|
||||||
use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};
|
use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};
|
||||||
use ruff_python_ast::{self as ast, Int, IpyEscapeKind};
|
use ruff_python_ast::{self as ast, Int, IpyEscapeKind};
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -12,8 +12,8 @@ use self::traits::{NotificationHandler, RequestHandler};
|
||||||
|
|
||||||
use super::{client::Responder, schedule::BackgroundSchedule, Result};
|
use super::{client::Responder, schedule::BackgroundSchedule, Result};
|
||||||
|
|
||||||
/// Defines the `document_url` method for implementors of [`traits::Notification`] and [`traits::Request`],
|
/// Defines the `document_url` method for implementers of [`traits::Notification`] and [`traits::Request`],
|
||||||
/// given the parameter type used by the implementor.
|
/// given the parameter type used by the implementer.
|
||||||
macro_rules! define_document_url {
|
macro_rules! define_document_url {
|
||||||
($params:ident: &$p:ty) => {
|
($params:ident: &$p:ty) => {
|
||||||
fn document_url($params: &$p) -> &lsp_types::Url {
|
fn document_url($params: &$p) -> &lsp_types::Url {
|
||||||
|
|
|
@ -289,7 +289,7 @@ def test(a, b, c, d, e, f) -> int: # fmt: skip
|
||||||
pass
|
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`:
|
the following example, the list entry `'1'` will be formatted, despite the `# fmt: skip`:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -157,7 +157,7 @@ To see which rules are currently in preview, visit the [rules reference](rules.m
|
||||||
## Selecting single preview rules
|
## Selecting single preview rules
|
||||||
|
|
||||||
When preview mode is enabled, selecting rule categories or prefixes will include all preview rules that match.
|
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:
|
setting in your configuration file:
|
||||||
|
|
||||||
=== "pyproject.toml"
|
=== "pyproject.toml"
|
||||||
|
|
|
@ -8,7 +8,7 @@ Ruff uses a custom versioning scheme that uses the **minor** version number for
|
||||||
|
|
||||||
- A deprecated option or feature is removed
|
- A deprecated option or feature is removed
|
||||||
- Configuration changes in a backwards incompatible way
|
- 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 a new file type is promoted to stable
|
||||||
- Support for an end-of-life Python version is dropped
|
- Support for an end-of-life Python version is dropped
|
||||||
- Linter:
|
- Linter:
|
||||||
|
@ -44,7 +44,7 @@ Ruff uses a custom versioning scheme that uses the **minor** version number for
|
||||||
|
|
||||||
## Preview mode
|
## 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.
|
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:
|
When modifying or adding rules, we use the following guidelines:
|
||||||
|
|
||||||
- New rules are always be added in a preview mode
|
- New rules should always be added in preview mode
|
||||||
- New rules remain in preview mode for at least one minor release before being promoted to stable
|
- 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 are not be eligible for stability until `0.8.0`
|
- 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 behavior are not changed significantly in patch versions
|
- 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
|
- 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
|
- 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.
|
- **Unsafe**: Can be applied with explicit opt-in.
|
||||||
- **Safe**: Can be applied automatically.
|
- **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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue