From 597c5f912411725e17970fe9d34de4b0c33a8e85 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 10 Aug 2024 18:04:37 +0530 Subject: [PATCH] Update dependency black to v24 (#12728) --- .../flake8_annotations/rules/definition.rs | 52 +++++++++---------- .../rules/async_function_with_timeout.rs | 8 +-- .../rules/hardcoded_password_default.rs | 8 +-- .../rules/ssl_with_bad_defaults.rs | 8 +-- .../rules/boolean_positional_value_in_call.rs | 8 +-- .../boolean_type_hint_positional_argument.rs | 7 ++- .../rules/abstract_base_class.rs | 8 +-- .../function_call_in_argument_default.rs | 6 ++- .../rules/future_required_type_annotation.rs | 8 +-- .../future_rewritable_type_annotation.rs | 12 ++--- .../flake8_pyi/rules/any_eq_ne_annotation.rs | 8 +-- .../rules/bad_version_info_comparison.rs | 12 ++--- .../rules/complex_assignment_in_stub.rs | 5 +- .../rules/custom_type_var_return_type.rs | 20 +++---- .../flake8_pyi/rules/docstring_in_stubs.rs | 5 +- .../flake8_pyi/rules/exit_annotations.rs | 8 +-- .../rules/iter_method_return_iterable.rs | 8 +-- .../flake8_pyi/rules/non_self_return_type.rs | 26 ++++------ .../rules/numeric_literal_too_long.rs | 8 +-- .../rules/pre_pep570_positional_argument.rs | 6 +-- .../rules/quoted_annotation_in_stub.rs | 8 +-- .../rules/redundant_numeric_union.rs | 8 +-- .../rules/flake8_pyi/rules/simple_defaults.rs | 16 +++--- .../rules/str_or_repr_defined_in_stub.rs | 4 +- .../rules/string_or_bytes_too_long.rs | 8 +-- .../rules/stub_body_multiple_statements.rs | 5 +- .../rules/unused_private_type_definition.rs | 15 +++--- .../flake8_pytest_style/rules/fixture.rs | 38 +++++++------- .../rules/flake8_pytest_style/rules/marks.rs | 16 +++--- .../flake8_pytest_style/rules/parametrize.rs | 42 +++++++-------- .../rules/error_suffix_on_exception_name.rs | 8 +-- .../rules/invalid_first_argument_name.rs | 16 +++--- .../pycodestyle/rules/ambiguous_class_name.rs | 8 +-- .../rules/ambiguous_function_name.rs | 8 +-- .../rules/blank_before_after_class.rs | 6 ++- .../src/rules/pydocstyle/rules/if_needed.rs | 8 +-- .../src/rules/pydocstyle/rules/not_missing.rs | 19 ++++--- .../rules/forward_annotation_syntax_error.rs | 4 +- .../src/rules/pyflakes/rules/imports.rs | 5 +- .../pylint/rules/bad_dunder_method_name.rs | 8 +-- .../src/rules/pylint/rules/import_self.rs | 4 +- .../rules/pylint/rules/no_method_decorator.rs | 16 +++--- .../pylint/rules/property_with_parameters.rs | 11 ++-- .../pylint/rules/singledispatch_method.rs | 8 +-- .../rules/singledispatchmethod_function.rs | 8 +-- .../rules/pylint/rules/too_many_positional.rs | 8 +-- .../rules/lru_cache_with_maxsize_none.rs | 8 +-- .../rules/lru_cache_without_parameters.rs | 8 +-- .../pyupgrade/rules/quoted_annotation.rs | 11 ++-- .../rules/pyupgrade/rules/replace_str_enum.rs | 6 +-- .../pyupgrade/rules/useless_metaclass_type.rs | 5 +- .../rules/useless_object_inheritance.rs | 8 +-- .../src/rules/ruff/rules/never_union.rs | 8 +-- docs/requirements-insiders.txt | 2 +- docs/requirements.txt | 2 +- 55 files changed, 292 insertions(+), 302 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs index e43bb1676fa0c..34880b3ad2e12 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs @@ -24,15 +24,15 @@ use crate::rules::ruff::typing::type_hint_resolves_to_any; /// any provided arguments match expectation. /// /// ## Example +/// /// ```python -/// def foo(x): -/// ... +/// def foo(x): ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(x: int): -/// ... +/// def foo(x: int): ... /// ``` #[violation] pub struct MissingTypeFunctionArgument { @@ -56,15 +56,15 @@ impl Violation for MissingTypeFunctionArgument { /// any provided arguments match expectation. /// /// ## Example +/// /// ```python -/// def foo(*args): -/// ... +/// def foo(*args): ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(*args: int): -/// ... +/// def foo(*args: int): ... /// ``` #[violation] pub struct MissingTypeArgs { @@ -88,15 +88,15 @@ impl Violation for MissingTypeArgs { /// any provided arguments match expectation. /// /// ## Example +/// /// ```python -/// def foo(**kwargs): -/// ... +/// def foo(**kwargs): ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(**kwargs: int): -/// ... +/// def foo(**kwargs: int): ... /// ``` #[violation] pub struct MissingTypeKwargs { @@ -127,17 +127,17 @@ impl Violation for MissingTypeKwargs { /// annotation is not strictly necessary. /// /// ## Example +/// /// ```python /// class Foo: -/// def bar(self): -/// ... +/// def bar(self): ... /// ``` /// /// Use instead: +/// /// ```python /// class Foo: -/// def bar(self: "Foo"): -/// ... +/// def bar(self: "Foo"): ... /// ``` #[violation] pub struct MissingTypeSelf { @@ -168,19 +168,19 @@ impl Violation for MissingTypeSelf { /// annotation is not strictly necessary. /// /// ## Example +/// /// ```python /// class Foo: /// @classmethod -/// def bar(cls): -/// ... +/// def bar(cls): ... /// ``` /// /// Use instead: +/// /// ```python /// class Foo: /// @classmethod -/// def bar(cls: Type["Foo"]): -/// ... +/// def bar(cls: Type["Foo"]): ... /// ``` #[violation] pub struct MissingTypeCls { @@ -449,29 +449,29 @@ impl Violation for MissingReturnTypeClassMethod { /// `Any` as an "escape hatch" only when it is really needed. /// /// ## Example +/// /// ```python -/// def foo(x: Any): -/// ... +/// def foo(x: Any): ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(x: int): -/// ... +/// def foo(x: int): ... /// ``` /// /// ## Known problems /// /// Type aliases are unsupported and can lead to false positives. /// For example, the following will trigger this rule inadvertently: +/// /// ```python /// from typing import Any /// /// MyAny = Any /// /// -/// def foo(x: MyAny): -/// ... +/// def foo(x: MyAny): ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs b/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs index 2edc094fc6196..07e7c16e40bf5 100644 --- a/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs +++ b/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs @@ -17,9 +17,9 @@ use crate::settings::types::PreviewMode; /// or `anyio.move_on_after`, among others. /// /// ## Example +/// /// ```python -/// async def long_running_task(timeout): -/// ... +/// async def long_running_task(timeout): ... /// /// /// async def main(): @@ -27,9 +27,9 @@ use crate::settings::types::PreviewMode; /// ``` /// /// Use instead: +/// /// ```python -/// async def long_running_task(): -/// ... +/// async def long_running_task(): ... /// /// /// async def main(): diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_default.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_default.rs index 969364a271a35..ade608a1d5829 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_default.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_default.rs @@ -22,18 +22,18 @@ use super::super::helpers::{matches_password_name, string_literal}; /// control. /// /// ## Example +/// /// ```python -/// def connect_to_server(password="hunter2"): -/// ... +/// def connect_to_server(password="hunter2"): ... /// ``` /// /// Use instead: +/// /// ```python /// import os /// /// -/// def connect_to_server(password=os.environ["PASSWORD"]): -/// ... +/// def connect_to_server(password=os.environ["PASSWORD"]): ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/ssl_with_bad_defaults.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/ssl_with_bad_defaults.rs index da60e3736d616..bfff9cbf343d0 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/ssl_with_bad_defaults.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/ssl_with_bad_defaults.rs @@ -18,21 +18,21 @@ use crate::checkers::ast::Checker; /// - TLS v1.1 /// /// ## Example +/// /// ```python /// import ssl /// /// -/// def func(version=ssl.PROTOCOL_TLSv1): -/// ... +/// def func(version=ssl.PROTOCOL_TLSv1): ... /// ``` /// /// Use instead: +/// /// ```python /// import ssl /// /// -/// def func(version=ssl.PROTOCOL_TLSv1_2): -/// ... +/// def func(version=ssl.PROTOCOL_TLSv1_2): ... /// ``` #[violation] pub struct SslWithBadDefaults { diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs index e89b91c4929fd..45aade82696a4 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs @@ -18,18 +18,18 @@ use crate::rules::flake8_boolean_trap::helpers::allow_boolean_trap; /// readers of the code. /// /// ## Example +/// /// ```python -/// def func(flag: bool) -> None: -/// ... +/// def func(flag: bool) -> None: ... /// /// /// func(True) /// ``` /// /// Use instead: +/// /// ```python -/// def func(flag: bool) -> None: -/// ... +/// def func(flag: bool) -> None: ... /// /// /// func(flag=True) diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs index 96b6df9690bb0..7b39217ad7935 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs @@ -31,6 +31,7 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// variants, like `bool | int`. /// /// ## Example +/// /// ```python /// from math import ceil, floor /// @@ -44,6 +45,7 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// ``` /// /// Instead, refactor into separate implementations: +/// /// ```python /// from math import ceil, floor /// @@ -61,6 +63,7 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// ``` /// /// Or, refactor to use an `Enum`: +/// /// ```python /// from enum import Enum /// @@ -70,11 +73,11 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; /// DOWN = 2 /// /// -/// def round_number(value: float, method: RoundingMethod) -> float: -/// ... +/// def round_number(value: float, method: RoundingMethod) -> float: ... /// ``` /// /// Or, make the argument a keyword-only argument: +/// /// ```python /// from math import ceil, floor /// diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs index a927703d97dbd..410c210b174a5 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs @@ -67,24 +67,24 @@ impl Violation for AbstractBaseClassWithoutAbstractMethod { /// `@abstractmethod` decorator to the method. /// /// ## Example +/// /// ```python /// from abc import ABC /// /// /// class Foo(ABC): -/// def method(self): -/// ... +/// def method(self): ... /// ``` /// /// Use instead: +/// /// ```python /// from abc import ABC, abstractmethod /// /// /// class Foo(ABC): /// @abstractmethod -/// def method(self): -/// ... +/// def method(self): ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs index a6a30a8d20f65..4e356e66f2bac 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs @@ -30,6 +30,7 @@ use crate::checkers::ast::Checker; /// [`lint.flake8-bugbear.extend-immutable-calls`] configuration option as well. /// /// ## Example +/// /// ```python /// def create_list() -> list[int]: /// return [1, 2, 3] @@ -41,6 +42,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// Use instead: +/// /// ```python /// def better(arg: list[int] | None = None) -> list[int]: /// if arg is None: @@ -52,12 +54,12 @@ use crate::checkers::ast::Checker; /// /// If the use of a singleton is intentional, assign the result call to a /// module-level variable, and use that variable in the default argument: +/// /// ```python /// ERROR = ValueError("Hosts weren't successfully added") /// /// -/// def add_host(error: Exception = ERROR) -> None: -/// ... +/// def add_host(error: Exception = ERROR) -> None: ... /// ``` /// /// ## Options diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs b/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs index 8895b374a0f37..ae39f653c844f 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs @@ -29,18 +29,18 @@ use crate::checkers::ast::Checker; /// flag such usages if your project targets Python 3.9 or below. /// /// ## Example +/// /// ```python -/// def func(obj: dict[str, int | None]) -> None: -/// ... +/// def func(obj: dict[str, int | None]) -> None: ... /// ``` /// /// Use instead: +/// /// ```python /// from __future__ import annotations /// /// -/// def func(obj: dict[str, int | None]) -> None: -/// ... +/// def func(obj: dict[str, int | None]) -> None: ... /// ``` /// /// ## Fix safety diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs b/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs index 6c8aa08177d95..c6e4b2bf96ac8 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs @@ -33,32 +33,32 @@ use crate::checkers::ast::Checker; /// flag such usages if your project targets Python 3.9 or below. /// /// ## Example +/// /// ```python /// from typing import List, Dict, Optional /// /// -/// def func(obj: Dict[str, Optional[int]]) -> None: -/// ... +/// def func(obj: Dict[str, Optional[int]]) -> None: ... /// ``` /// /// Use instead: +/// /// ```python /// from __future__ import annotations /// /// from typing import List, Dict, Optional /// /// -/// def func(obj: Dict[str, Optional[int]]) -> None: -/// ... +/// def func(obj: Dict[str, Optional[int]]) -> None: ... /// ``` /// /// After running the additional pyupgrade rules: +/// /// ```python /// from __future__ import annotations /// /// -/// def func(obj: dict[str, int | None]) -> None: -/// ... +/// def func(obj: dict[str, int | None]) -> None: ... /// ``` /// /// ## Options diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs index 3a8e5f2d05ef5..d2038aecbec86 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs @@ -26,17 +26,17 @@ use crate::checkers::ast::Checker; /// these comparison operators -- `__eq__` and `__ne__`. /// /// ## Example +/// /// ```python /// class Foo: -/// def __eq__(self, obj: typing.Any) -> bool: -/// ... +/// def __eq__(self, obj: typing.Any) -> bool: ... /// ``` /// /// Use instead: +/// /// ```python /// class Foo: -/// def __eq__(self, obj: object) -> bool: -/// ... +/// def __eq__(self, obj: object) -> bool: ... /// ``` /// ## References /// - [Python documentation: The `Any` type](https://docs.python.org/3/library/typing.html#the-any-type) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs index ecafa4a1b742b..c8c5834605af9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs @@ -75,13 +75,11 @@ impl Violation for BadVersionInfoComparison { /// /// if sys.version_info < (3, 10): /// -/// def read_data(x, *, preserve_order=True): -/// ... +/// def read_data(x, *, preserve_order=True): ... /// /// else: /// -/// def read_data(x): -/// ... +/// def read_data(x): ... /// ``` /// /// Use instead: @@ -89,13 +87,11 @@ impl Violation for BadVersionInfoComparison { /// ```python /// if sys.version_info >= (3, 10): /// -/// def read_data(x): -/// ... +/// def read_data(x): ... /// /// else: /// -/// def read_data(x, *, preserve_order=True): -/// ... +/// def read_data(x, *, preserve_order=True): ... /// ``` #[violation] pub struct BadVersionInfoOrder; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs index 7111b1212f596..5f33284ee9ce7 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs @@ -19,20 +19,21 @@ use crate::checkers::ast::Checker; /// used. /// /// ## Example +/// /// ```python /// from typing import TypeAlias /// /// a = b = int /// /// -/// class Klass: -/// ... +/// class Klass: ... /// /// /// Klass.X: TypeAlias = int /// ``` /// /// Use instead: +/// /// ```python /// from typing import TypeAlias /// diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs index 31f5dc952b52d..07b5e093b824a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs @@ -24,34 +24,30 @@ use crate::checkers::ast::Checker; /// methods that return an instance of `cls`, and `__new__` methods. /// /// ## Example +/// /// ```python /// class Foo: -/// def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: -/// ... +/// def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... /// -/// def foo(self: _S, arg: bytes) -> _S: -/// ... +/// def foo(self: _S, arg: bytes) -> _S: ... /// /// @classmethod -/// def bar(cls: type[_S], arg: int) -> _S: -/// ... +/// def bar(cls: type[_S], arg: int) -> _S: ... /// ``` /// /// Use instead: +/// /// ```python /// from typing import Self /// /// /// class Foo: -/// def __new__(cls, *args: str, **kwargs: int) -> Self: -/// ... +/// def __new__(cls, *args: str, **kwargs: int) -> Self: ... /// -/// def foo(self, arg: bytes) -> Self: -/// ... +/// def foo(self, arg: bytes) -> Self: ... /// /// @classmethod -/// def bar(cls, arg: int) -> Self: -/// ... +/// def bar(cls, arg: int) -> Self: ... /// ``` /// /// [PEP 673]: https://peps.python.org/pep-0673/#motivation diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/docstring_in_stubs.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/docstring_in_stubs.rs index 65c092a3f5471..4eceb88fdeb91 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/docstring_in_stubs.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/docstring_in_stubs.rs @@ -14,6 +14,7 @@ use crate::checkers::ast::Checker; /// hints, rather than documentation. /// /// ## Example +/// /// ```python /// def func(param: int) -> str: /// """This is a docstring.""" @@ -21,9 +22,9 @@ use crate::checkers::ast::Checker; /// ``` /// /// Use instead: +/// /// ```python -/// def func(param: int) -> str: -/// ... +/// def func(param: int) -> str: ... /// ``` #[violation] pub struct DocstringInStub; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs index 3e42284a0b793..c2ea9df8e5a4f 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs @@ -23,6 +23,7 @@ use crate::checkers::ast::Checker; /// unexpected behavior when interacting with type checkers. /// /// ## Example +/// /// ```python /// from types import TracebackType /// @@ -30,11 +31,11 @@ use crate::checkers::ast::Checker; /// class Foo: /// def __exit__( /// self, typ: BaseException, exc: BaseException, tb: TracebackType -/// ) -> None: -/// ... +/// ) -> None: ... /// ``` /// /// Use instead: +/// /// ```python /// from types import TracebackType /// @@ -45,8 +46,7 @@ use crate::checkers::ast::Checker; /// typ: type[BaseException] | None, /// exc: BaseException | None, /// tb: TracebackType | None, -/// ) -> None: -/// ... +/// ) -> None: ... /// ``` #[violation] pub struct BadExitAnnotation { diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs index 017b3947a8b22..a2e0244b741b0 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs @@ -50,23 +50,23 @@ use crate::checkers::ast::Checker; /// on the returned object, violating the expectations of the interface. /// /// ## Example +/// /// ```python /// import collections.abc /// /// /// class Klass: -/// def __iter__(self) -> collections.abc.Iterable[str]: -/// ... +/// def __iter__(self) -> collections.abc.Iterable[str]: ... /// ``` /// /// Use instead: +/// /// ```python /// import collections.abc /// /// /// class Klass: -/// def __iter__(self) -> collections.abc.Iterator[str]: -/// ... +/// def __iter__(self) -> collections.abc.Iterator[str]: ... /// ``` #[violation] pub struct IterMethodReturnIterable { diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs index 42c7399e61533..652e7632d952b 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs @@ -50,38 +50,32 @@ use crate::checkers::ast::Checker; /// inheriting directly from `AsyncIterator`. /// /// ## Example +/// /// ```python /// class Foo: -/// def __new__(cls, *args: Any, **kwargs: Any) -> Foo: -/// ... +/// def __new__(cls, *args: Any, **kwargs: Any) -> Foo: ... /// -/// def __enter__(self) -> Foo: -/// ... +/// def __enter__(self) -> Foo: ... /// -/// async def __aenter__(self) -> Foo: -/// ... +/// async def __aenter__(self) -> Foo: ... /// -/// def __iadd__(self, other: Foo) -> Foo: -/// ... +/// def __iadd__(self, other: Foo) -> Foo: ... /// ``` /// /// Use instead: +/// /// ```python /// from typing_extensions import Self /// /// /// class Foo: -/// def __new__(cls, *args: Any, **kwargs: Any) -> Self: -/// ... +/// def __new__(cls, *args: Any, **kwargs: Any) -> Self: ... /// -/// def __enter__(self) -> Self: -/// ... +/// def __enter__(self) -> Self: ... /// -/// async def __aenter__(self) -> Self: -/// ... +/// async def __aenter__(self) -> Self: ... /// -/// def __iadd__(self, other: Foo) -> Self: -/// ... +/// def __iadd__(self, other: Foo) -> Self: ... /// ``` /// ## References /// - [`typing.Self` documentation](https://docs.python.org/3/library/typing.html#typing.Self) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs index 97759b3f77a95..9930f6c19e0e9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs @@ -19,15 +19,15 @@ use crate::checkers::ast::Checker; /// ellipses (`...`) instead. /// /// ## Example +/// /// ```python -/// def foo(arg: int = 693568516352839939918568862861217771399698285293568) -> None: -/// ... +/// def foo(arg: int = 693568516352839939918568862861217771399698285293568) -> None: ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(arg: int = ...) -> None: -/// ... +/// def foo(arg: int = ...) -> None: ... /// ``` #[violation] pub struct NumericLiteralTooLong; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/pre_pep570_positional_argument.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/pre_pep570_positional_argument.rs index 92e45497022d5..d24a284978d10 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/pre_pep570_positional_argument.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/pre_pep570_positional_argument.rs @@ -18,15 +18,13 @@ use crate::settings::types::PythonVersion; /// ## Example /// /// ```python -/// def foo(__x: int) -> None: -/// ... +/// def foo(__x: int) -> None: ... /// ``` /// /// Use instead: /// /// ```python -/// def foo(x: int, /) -> None: -/// ... +/// def foo(x: int, /) -> None: ... /// ``` /// /// [PEP 484]: https://peps.python.org/pep-0484/#positional-only-arguments diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs index f79a0103ca287..a3cc1e400bb03 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs @@ -15,15 +15,15 @@ use crate::checkers::ast::Checker; /// annotations in stub files, and should be omitted. /// /// ## Example +/// /// ```python -/// def function() -> "int": -/// ... +/// def function() -> "int": ... /// ``` /// /// Use instead: +/// /// ```python -/// def function() -> int: -/// ... +/// def function() -> int: ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs index 5e8651b5389cf..3a64c72530b98 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs @@ -26,15 +26,15 @@ use crate::checkers::ast::Checker; /// redundant elements. /// /// ## Example +/// /// ```python -/// def foo(x: float | int | str) -> None: -/// ... +/// def foo(x: float | int | str) -> None: ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(x: float | str) -> None: -/// ... +/// def foo(x: float | str) -> None: ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs index 2d66fc868df40..9f40e350a6778 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs @@ -30,15 +30,15 @@ use crate::settings::types::PythonVersion; /// or a simple container literal. /// /// ## Example +/// /// ```python -/// def foo(arg: list[int] = list(range(10_000))) -> None: -/// ... +/// def foo(arg: list[int] = list(range(10_000))) -> None: ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(arg: list[int] = ...) -> None: -/// ... +/// def foo(arg: list[int] = ...) -> None: ... /// ``` /// /// ## References @@ -76,15 +76,15 @@ impl AlwaysFixableViolation for TypedArgumentDefaultInStub { /// or varies according to the current platform or Python version. /// /// ## Example +/// /// ```python -/// def foo(arg=[]) -> None: -/// ... +/// def foo(arg=[]) -> None: ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(arg=...) -> None: -/// ... +/// def foo(arg=...) -> None: ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs index 051e702606247..9d40deaa2f447 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs @@ -18,10 +18,10 @@ use crate::fix::edits::delete_stmt; /// equivalent, `object.__str__` and `object.__repr__`, respectively. /// /// ## Example +/// /// ```python /// class Foo: -/// def __repr__(self) -> str: -/// ... +/// def __repr__(self) -> str: ... /// ``` #[violation] pub struct StrOrReprDefinedInStub { diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs index 277b07c5e375d..8f50173f25583 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs @@ -22,15 +22,15 @@ use crate::checkers::ast::Checker; /// with ellipses (`...`) to simplify the stub. /// /// ## Example +/// /// ```python -/// def foo(arg: str = "51 character stringgggggggggggggggggggggggggggggggg") -> None: -/// ... +/// def foo(arg: str = "51 character stringgggggggggggggggggggggggggggggggg") -> None: ... /// ``` /// /// Use instead: +/// /// ```python -/// def foo(arg: str = ...) -> None: -/// ... +/// def foo(arg: str = ...) -> None: ... /// ``` #[violation] pub struct StringOrBytesTooLong; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs index efe4b918f7d22..34d33fea62334 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs @@ -15,6 +15,7 @@ use crate::checkers::ast::Checker; /// should instead contain only a single statement (e.g., `...`). /// /// ## Example +/// /// ```python /// def function(): /// x = 1 @@ -23,9 +24,9 @@ use crate::checkers::ast::Checker; /// ``` /// /// Use instead: +/// /// ```python -/// def function(): -/// ... +/// def function(): ... /// ``` #[violation] pub struct StubBodyMultipleStatements; diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs index 493bdbd7bf5dd..0407986ccb928 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs @@ -49,6 +49,7 @@ impl Violation for UnusedPrivateTypeVar { /// confusion. /// /// ## Example +/// /// ```python /// import typing /// @@ -58,6 +59,7 @@ impl Violation for UnusedPrivateTypeVar { /// ``` /// /// Use instead: +/// /// ```python /// import typing /// @@ -66,8 +68,7 @@ impl Violation for UnusedPrivateTypeVar { /// foo: int /// /// -/// def func(arg: _PrivateProtocol) -> None: -/// ... +/// def func(arg: _PrivateProtocol) -> None: ... /// ``` #[violation] pub struct UnusedPrivateProtocol { @@ -91,6 +92,7 @@ impl Violation for UnusedPrivateProtocol { /// confusion. /// /// ## Example +/// /// ```python /// import typing /// @@ -98,14 +100,14 @@ impl Violation for UnusedPrivateProtocol { /// ``` /// /// Use instead: +/// /// ```python /// import typing /// /// _UsedTypeAlias: typing.TypeAlias = int /// /// -/// def func(arg: _UsedTypeAlias) -> _UsedTypeAlias: -/// ... +/// def func(arg: _UsedTypeAlias) -> _UsedTypeAlias: ... /// ``` #[violation] pub struct UnusedPrivateTypeAlias { @@ -129,6 +131,7 @@ impl Violation for UnusedPrivateTypeAlias { /// confusion. /// /// ## Example +/// /// ```python /// import typing /// @@ -138,6 +141,7 @@ impl Violation for UnusedPrivateTypeAlias { /// ``` /// /// Use instead: +/// /// ```python /// import typing /// @@ -146,8 +150,7 @@ impl Violation for UnusedPrivateTypeAlias { /// foo: set[str] /// /// -/// def func(arg: _UsedPrivateTypedDict) -> _UsedPrivateTypedDict: -/// ... +/// def func(arg: _UsedPrivateTypedDict) -> _UsedPrivateTypedDict: ... /// ``` #[violation] pub struct UnusedPrivateTypedDict { diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs index 9b227a46c10ff..b9688ede2f2fd 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs @@ -38,23 +38,23 @@ use super::helpers::{ /// the behavior of official pytest projects. /// /// ## Example +/// /// ```python /// import pytest /// /// /// @pytest.fixture -/// def my_fixture(): -/// ... +/// def my_fixture(): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// /// /// @pytest.fixture() -/// def my_fixture(): -/// ... +/// def my_fixture(): ... /// ``` /// /// ## Options @@ -94,23 +94,23 @@ impl AlwaysFixableViolation for PytestFixtureIncorrectParenthesesStyle { /// fixture configuration. /// /// ## Example +/// /// ```python /// import pytest /// /// /// @pytest.fixture("module") -/// def my_fixture(): -/// ... +/// def my_fixture(): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// /// /// @pytest.fixture(scope="module") -/// def my_fixture(): -/// ... +/// def my_fixture(): ... /// ``` /// /// ## References @@ -135,23 +135,23 @@ impl Violation for PytestFixturePositionalArgs { /// `scope="function"` can be omitted, as it is the default. /// /// ## Example +/// /// ```python /// import pytest /// /// /// @pytest.fixture(scope="function") -/// def my_fixture(): -/// ... +/// def my_fixture(): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// /// /// @pytest.fixture() -/// def my_fixture(): -/// ... +/// def my_fixture(): ... /// ``` /// /// ## References @@ -303,32 +303,30 @@ impl Violation for PytestIncorrectFixtureNameUnderscore { /// and avoid the confusion caused by unused arguments. /// /// ## Example +/// /// ```python /// import pytest /// /// /// @pytest.fixture -/// def _patch_something(): -/// ... +/// def _patch_something(): ... /// /// -/// def test_foo(_patch_something): -/// ... +/// def test_foo(_patch_something): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// /// /// @pytest.fixture -/// def _patch_something(): -/// ... +/// def _patch_something(): ... /// /// /// @pytest.mark.usefixtures("_patch_something") -/// def test_foo(): -/// ... +/// def test_foo(): ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs index b3beac0119227..f27717b293348 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs @@ -25,23 +25,23 @@ use super::helpers::get_mark_decorators; /// fixtures is fine, but it's best to be consistent. /// /// ## Example +/// /// ```python /// import pytest /// /// /// @pytest.mark.foo -/// def test_something(): -/// ... +/// def test_something(): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// /// /// @pytest.mark.foo() -/// def test_something(): -/// ... +/// def test_something(): ... /// ``` /// /// ## Options @@ -86,19 +86,19 @@ impl AlwaysFixableViolation for PytestIncorrectMarkParenthesesStyle { /// useless and should be removed. /// /// ## Example +/// /// ```python /// import pytest /// /// /// @pytest.mark.usefixtures() -/// def test_something(): -/// ... +/// def test_something(): ... /// ``` /// /// Use instead: +/// /// ```python -/// def test_something(): -/// ... +/// def test_something(): ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs index c9d4501622e9d..b93ccbb58e26e 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs @@ -27,41 +27,38 @@ use super::helpers::{is_pytest_parametrize, split_names}; /// configured via the [`lint.flake8-pytest-style.parametrize-names-type`] setting. /// /// ## Example +/// /// ```python /// import pytest /// /// /// # single parameter, always expecting string /// @pytest.mark.parametrize(("param",), [1, 2, 3]) -/// def test_foo(param): -/// ... +/// def test_foo(param): ... /// /// /// # multiple parameters, expecting tuple /// @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -/// def test_bar(param1, param2): -/// ... +/// def test_bar(param1, param2): ... /// /// /// # multiple parameters, expecting tuple /// @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) -/// def test_baz(param1, param2): -/// ... +/// def test_baz(param1, param2): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// /// /// @pytest.mark.parametrize("param", [1, 2, 3]) -/// def test_foo(param): -/// ... +/// def test_foo(param): ... /// /// /// @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -/// def test_bar(param1, param2): -/// ... +/// def test_bar(param1, param2): ... /// ``` /// /// ## Options @@ -149,14 +146,14 @@ impl Violation for PytestParametrizeNamesWrongType { /// - `list`: `@pytest.mark.parametrize(("key", "value"), [["a", "b"], ["c", "d"]])` /// /// ## Example +/// /// ```python /// import pytest /// /// /// # expected list, got tuple /// @pytest.mark.parametrize("param", (1, 2)) -/// def test_foo(param): -/// ... +/// def test_foo(param): ... /// /// /// # expected top-level list, got tuple @@ -167,8 +164,7 @@ impl Violation for PytestParametrizeNamesWrongType { /// (3, 4), /// ), /// ) -/// def test_bar(param1, param2): -/// ... +/// def test_bar(param1, param2): ... /// /// /// # expected individual rows to be tuples, got lists @@ -179,23 +175,21 @@ impl Violation for PytestParametrizeNamesWrongType { /// [3, 4], /// ], /// ) -/// def test_baz(param1, param2): -/// ... +/// def test_baz(param1, param2): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// /// /// @pytest.mark.parametrize("param", [1, 2, 3]) -/// def test_foo(param): -/// ... +/// def test_foo(param): ... /// /// /// @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -/// def test_bar(param1, param2): -/// ... +/// def test_bar(param1, param2): ... /// ``` /// /// ## Options @@ -232,6 +226,7 @@ impl Violation for PytestParametrizeValuesWrongType { /// Duplicate test cases are redundant and should be removed. /// /// ## Example +/// /// ```python /// import pytest /// @@ -243,11 +238,11 @@ impl Violation for PytestParametrizeValuesWrongType { /// (1, 2), /// ], /// ) -/// def test_foo(param1, param2): -/// ... +/// def test_foo(param1, param2): ... /// ``` /// /// Use instead: +/// /// ```python /// import pytest /// @@ -258,8 +253,7 @@ impl Violation for PytestParametrizeValuesWrongType { /// (1, 2), /// ], /// ) -/// def test_foo(param1, param2): -/// ... +/// def test_foo(param1, param2): ... /// ``` /// /// ## Fix safety diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs index 0b3cf3925174e..5cab715917152 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs @@ -17,15 +17,15 @@ use crate::rules::pep8_naming::settings::IgnoreNames; /// > exception names (if the exception actually is an error). /// /// ## Example +/// /// ```python -/// class Validation(Exception): -/// ... +/// class Validation(Exception): ... /// ``` /// /// Use instead: +/// /// ```python -/// class ValidationError(Exception): -/// ... +/// class ValidationError(Exception): ... /// ``` /// /// [PEP 8]: https://peps.python.org/pep-0008/#exception-names diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name.rs index c43f2fafe59f3..5f5cefadf4d46 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name.rs @@ -34,17 +34,17 @@ use crate::renamer::Renamer; /// the [`lint.pep8-naming.extend-ignore-names`] option to `["this"]`. /// /// ## Example +/// /// ```python /// class Example: -/// def function(cls, data): -/// ... +/// def function(cls, data): ... /// ``` /// /// Use instead: +/// /// ```python /// class Example: -/// def function(self, data): -/// ... +/// def function(self, data): ... /// ``` /// /// ## Fix safety @@ -98,19 +98,19 @@ impl Violation for InvalidFirstArgumentNameForMethod { /// the [`lint.pep8-naming.extend-ignore-names`] option to `["klass"]`. /// /// ## Example +/// /// ```python /// class Example: /// @classmethod -/// def function(self, data): -/// ... +/// def function(self, data): ... /// ``` /// /// Use instead: +/// /// ```python /// class Example: /// @classmethod -/// def function(cls, data): -/// ... +/// def function(cls, data): ... /// ``` /// /// ## Fix safety diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_class_name.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_class_name.rs index 687f3f592a77d..0729cdab66743 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_class_name.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_class_name.rs @@ -14,15 +14,15 @@ use crate::rules::pycodestyle::helpers::is_ambiguous_name; /// numerals one and zero. When tempted to use 'l', use 'L' instead. /// /// ## Example +/// /// ```python -/// class I(object): -/// ... +/// class I(object): ... /// ``` /// /// Use instead: +/// /// ```python -/// class Integer(object): -/// ... +/// class Integer(object): ... /// ``` #[violation] pub struct AmbiguousClassName(pub String); diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_function_name.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_function_name.rs index 678f48d5b8730..6601929c9819e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_function_name.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_function_name.rs @@ -14,15 +14,15 @@ use crate::rules::pycodestyle::helpers::is_ambiguous_name; /// numerals one and zero. When tempted to use 'l', use 'L' instead. /// /// ## Example +/// /// ```python -/// def l(x): -/// ... +/// def l(x): ... /// ``` /// /// Use instead: +/// /// ```python -/// def long_name(x): -/// ... +/// def long_name(x): ... /// ``` #[violation] pub struct AmbiguousFunctionName(pub String); diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs index 4565f12cbc362..26149fdfb4428 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs @@ -24,15 +24,16 @@ use crate::registry::Rule; /// For an alternative, see [D211]. /// /// ## Example +/// /// ```python /// class PhotoMetadata: /// """Metadata about a photo.""" /// ``` /// /// Use instead: +/// /// ```python /// class PhotoMetadata: -/// /// """Metadata about a photo.""" /// ``` /// @@ -121,13 +122,14 @@ impl AlwaysFixableViolation for OneBlankLineAfterClass { /// For an alternative, see [D203]. /// /// ## Example +/// /// ```python /// class PhotoMetadata: -/// /// """Metadata about a photo.""" /// ``` /// /// Use instead: +/// /// ```python /// class PhotoMetadata: /// """Metadata about a photo.""" diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/if_needed.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/if_needed.rs index e4880a609d0bf..1138b1d5fab46 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/if_needed.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/if_needed.rs @@ -20,6 +20,7 @@ use crate::docstrings::Docstring; /// the implementation. /// /// ## Example +/// /// ```python /// from typing import overload /// @@ -42,18 +43,17 @@ use crate::docstrings::Docstring; /// ``` /// /// Use instead: +/// /// ```python /// from typing import overload /// /// /// @overload -/// def factorial(n: int) -> int: -/// ... +/// def factorial(n: int) -> int: ... /// /// /// @overload -/// def factorial(n: float) -> float: -/// ... +/// def factorial(n: float) -> float: ... /// /// /// def factorial(n): diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs index 6d1242887a149..347e0a6a83304 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs @@ -28,16 +28,16 @@ use crate::registry::Rule; /// that format for consistency. /// /// ## Example +/// /// ```python -/// class FasterThanLightError(ZeroDivisionError): -/// ... +/// class FasterThanLightError(ZeroDivisionError): ... /// /// -/// def calculate_speed(distance: float, time: float) -> float: -/// ... +/// def calculate_speed(distance: float, time: float) -> float: ... /// ``` /// /// Use instead: +/// /// ```python /// """Utility functions and classes for calculating speed. /// @@ -47,12 +47,10 @@ use crate::registry::Rule; /// """ /// /// -/// class FasterThanLightError(ZeroDivisionError): -/// ... +/// class FasterThanLightError(ZeroDivisionError): ... /// /// -/// def calculate_speed(distance: float, time: float) -> float: -/// ... +/// def calculate_speed(distance: float, time: float) -> float: ... /// ``` /// /// ## References @@ -430,12 +428,12 @@ impl Violation for UndocumentedMagicMethod { /// that format for consistency. /// /// ## Example +/// /// ```python /// class Foo: /// """Class Foo.""" /// -/// class Bar: -/// ... +/// class Bar: ... /// /// /// bar = Foo.Bar() @@ -443,6 +441,7 @@ impl Violation for UndocumentedMagicMethod { /// ``` /// /// Use instead: +/// /// ```python /// class Foo: /// """Class Foo.""" diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs b/crates/ruff_linter/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs index aa94f3eb0ae5e..7e0405111f50c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs @@ -15,9 +15,9 @@ use ruff_macros::{derive_message_formats, violation}; /// will instead raise an error when type checking is performed. /// /// ## Example +/// /// ```python -/// def foo() -> "/": -/// ... +/// def foo() -> "/": ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/imports.rs b/crates/ruff_linter/src/rules/pyflakes/rules/imports.rs index 6d1fc044d9963..bbd92f9adeead 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/imports.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/imports.rs @@ -177,18 +177,19 @@ impl Violation for UndefinedLocalWithImportStarUsage { /// module). /// /// ## Example +/// /// ```python /// def foo(): /// from math import * /// ``` /// /// Use instead: +/// /// ```python /// from math import * /// /// -/// def foo(): -/// ... +/// def foo(): ... /// ``` /// /// [PEP 8]: https://peps.python.org/pep-0008/#imports diff --git a/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs b/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs index 054b9a0d2008d..2812cf214aab5 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs @@ -27,17 +27,17 @@ use crate::rules::pylint::helpers::is_known_dunder_method; /// [`lint.pylint.allow-dunder-method-names`] setting. /// /// ## Example +/// /// ```python /// class Foo: -/// def __init_(self): -/// ... +/// def __init_(self): ... /// ``` /// /// Use instead: +/// /// ```python /// class Foo: -/// def __init__(self): -/// ... +/// def __init__(self): ... /// ``` /// /// ## Options diff --git a/crates/ruff_linter/src/rules/pylint/rules/import_self.rs b/crates/ruff_linter/src/rules/pylint/rules/import_self.rs index 802f11eb8b667..072285eabf690 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/import_self.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/import_self.rs @@ -12,13 +12,13 @@ use ruff_text_size::Ranged; /// Importing a module from itself is a circular dependency. /// /// ## Example +/// /// ```python /// # file: this_file.py /// from this_file import foo /// /// -/// def foo(): -/// ... +/// def foo(): ... /// ``` #[violation] pub struct ImportSelf { diff --git a/crates/ruff_linter/src/rules/pylint/rules/no_method_decorator.rs b/crates/ruff_linter/src/rules/pylint/rules/no_method_decorator.rs index a1648c8438a79..10d3390553771 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/no_method_decorator.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/no_method_decorator.rs @@ -17,20 +17,20 @@ use crate::fix; /// When it comes to consistency and readability, it's preferred to use the decorator. /// /// ## Example +/// /// ```python /// class Foo: -/// def bar(cls): -/// ... +/// def bar(cls): ... /// /// bar = classmethod(bar) /// ``` /// /// Use instead: +/// /// ```python /// class Foo: /// @classmethod -/// def bar(cls): -/// ... +/// def bar(cls): ... /// ``` #[violation] pub struct NoClassmethodDecorator; @@ -53,20 +53,20 @@ impl AlwaysFixableViolation for NoClassmethodDecorator { /// When it comes to consistency and readability, it's preferred to use the decorator. /// /// ## Example +/// /// ```python /// class Foo: -/// def bar(arg1, arg2): -/// ... +/// def bar(arg1, arg2): ... /// /// bar = staticmethod(bar) /// ``` /// /// Use instead: +/// /// ```python /// class Foo: /// @staticmethod -/// def bar(arg1, arg2): -/// ... +/// def bar(arg1, arg2): ... /// ``` #[violation] pub struct NoStaticmethodDecorator; diff --git a/crates/ruff_linter/src/rules/pylint/rules/property_with_parameters.rs b/crates/ruff_linter/src/rules/pylint/rules/property_with_parameters.rs index 16764ff3f715f..347866764ac6e 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/property_with_parameters.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/property_with_parameters.rs @@ -15,22 +15,21 @@ use crate::checkers::ast::Checker; /// desired parameters and call that method instead. /// /// ## Example +/// /// ```python /// class Cat: /// @property -/// def purr(self, volume): -/// ... +/// def purr(self, volume): ... /// ``` /// /// Use instead: +/// /// ```python /// class Cat: /// @property -/// def purr(self): -/// ... +/// def purr(self): ... /// -/// def purr_volume(self, volume): -/// ... +/// def purr_volume(self, volume): ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs b/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs index 8f1989217ff6f..70cc8c9d20124 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs @@ -18,25 +18,25 @@ use crate::importer::ImportRequest; /// standalone function. /// /// ## Example +/// /// ```python /// from functools import singledispatch /// /// /// class Class: /// @singledispatch -/// def method(self, arg): -/// ... +/// def method(self, arg): ... /// ``` /// /// Use instead: +/// /// ```python /// from functools import singledispatchmethod /// /// /// class Class: /// @singledispatchmethod -/// def method(self, arg): -/// ... +/// def method(self, arg): ... /// ``` /// /// ## Fix safety diff --git a/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs b/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs index fa51711cb391c..87b54cb203a6a 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs @@ -18,23 +18,23 @@ use crate::importer::ImportRequest; /// Instead, use the `@singledispatch` decorator. /// /// ## Example +/// /// ```python /// from functools import singledispatchmethod /// /// /// @singledispatchmethod -/// def func(arg): -/// ... +/// def func(arg): ... /// ``` /// /// Use instead: +/// /// ```python /// from functools import singledispatchmethod /// /// /// @singledispatch -/// def func(arg): -/// ... +/// def func(arg): ... /// ``` /// /// ## Fix safety diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_positional.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_positional.rs index 07f362a7972fc..44128953db50b 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_positional.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_positional.rs @@ -22,18 +22,18 @@ use crate::checkers::ast::Checker; /// [keyword-only arguments](https://docs.python.org/3/tutorial/controlflow.html#special-parameters). /// /// ## Example +/// /// ```python -/// def plot(x, y, z, color, mark, add_trendline): -/// ... +/// def plot(x, y, z, color, mark, add_trendline): ... /// /// /// plot(1, 2, 3, "r", "*", True) /// ``` /// /// Use instead: +/// /// ```python -/// def plot(x, y, z, *, color, mark, add_trendline): -/// ... +/// def plot(x, y, z, *, color, mark, add_trendline): ... /// /// /// plot(1, 2, 3, color="r", mark="*", add_trendline=True) diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs index 58317848dc241..febb7f59820c8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs @@ -16,23 +16,23 @@ use crate::importer::ImportRequest; /// `functools.cache` as it is more readable and idiomatic. /// /// ## Example +/// /// ```python /// import functools /// /// /// @functools.lru_cache(maxsize=None) -/// def foo(): -/// ... +/// def foo(): ... /// ``` /// /// Use instead: +/// /// ```python /// import functools /// /// /// @functools.cache -/// def foo(): -/// ... +/// def foo(): ... /// ``` /// /// ## Options diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs index 69ac48e29dc3b..48f1cf49c8676 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs @@ -13,23 +13,23 @@ use crate::checkers::ast::Checker; /// trailing parentheses, as long as no arguments are passed to it. /// /// ## Example +/// /// ```python /// import functools /// /// /// @functools.lru_cache() -/// def foo(): -/// ... +/// def foo(): ... /// ``` /// /// Use instead: +/// /// ```python /// import functools /// /// /// @functools.lru_cache -/// def foo(): -/// ... +/// def foo(): ... /// ``` /// /// ## Options diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs index 1476077de9ad1..a738b67286c5c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs @@ -21,31 +21,34 @@ use crate::checkers::ast::Checker; /// annotations on assignments in function bodies. /// /// ## Example +/// /// Given: +/// /// ```python /// from __future__ import annotations /// /// -/// def foo(bar: "Bar") -> "Bar": -/// ... +/// def foo(bar: "Bar") -> "Bar": ... /// ``` /// /// Use instead: +/// /// ```python /// from __future__ import annotations /// /// -/// def foo(bar: Bar) -> Bar: -/// ... +/// def foo(bar: Bar) -> Bar: ... /// ``` /// /// Given: +/// /// ```python /// def foo() -> None: /// bar: "Bar" /// ``` /// /// Use instead: +/// /// ```python /// def foo() -> None: /// bar: Bar diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/replace_str_enum.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/replace_str_enum.rs index d7d7724987b37..a5c9daaa63ed6 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/replace_str_enum.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/replace_str_enum.rs @@ -20,8 +20,7 @@ use crate::importer::ImportRequest; /// import enum /// /// -/// class Foo(str, enum.Enum): -/// ... +/// class Foo(str, enum.Enum): ... /// ``` /// /// Use instead: @@ -30,8 +29,7 @@ use crate::importer::ImportRequest; /// import enum /// /// -/// class Foo(enum.StrEnum): -/// ... +/// class Foo(enum.StrEnum): ... /// ``` /// /// ## Fix safety diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs index 612c94644cd8a..21d4b67448055 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs @@ -14,15 +14,16 @@ use crate::fix; /// Since Python 3, `__metaclass__ = type` is implied and can thus be omitted. /// /// ## Example +/// /// ```python /// class Foo: /// __metaclass__ = type /// ``` /// /// Use instead: +/// /// ```python -/// class Foo: -/// ... +/// class Foo: ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs index cbe88ab380d61..2b02baeaa2aa3 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs @@ -14,15 +14,15 @@ use crate::fix::edits::{remove_argument, Parentheses}; /// be omitted from the list of base classes. /// /// ## Example +/// /// ```python -/// class Foo(object): -/// ... +/// class Foo(object): ... /// ``` /// /// Use instead: +/// /// ```python -/// class Foo: -/// ... +/// class Foo: ... /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/ruff/rules/never_union.rs b/crates/ruff_linter/src/rules/ruff/rules/never_union.rs index f68983834e252..c96c3ed5600d3 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/never_union.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/never_union.rs @@ -16,18 +16,18 @@ use crate::checkers::ast::Checker; /// as, e.g., `typing.Never | T` is equivalent to `T`. /// /// ## Example +/// /// ```python /// from typing import Never /// /// -/// def func() -> Never | int: -/// ... +/// def func() -> Never | int: ... /// ``` /// /// Use instead: +/// /// ```python -/// def func() -> int: -/// ... +/// def func() -> int: ... /// ``` /// /// ## References diff --git a/docs/requirements-insiders.txt b/docs/requirements-insiders.txt index acca188f4864d..92a1195771ff8 100644 --- a/docs/requirements-insiders.txt +++ b/docs/requirements-insiders.txt @@ -1,5 +1,5 @@ PyYAML==6.0.1 -black==23.10.0 +black==24.3.0 mkdocs==1.5.0 mkdocs-material @ git+ssh://git@github.com/astral-sh/mkdocs-material-insiders.git@38c0b8187325c3bab386b666daf3518ac036f2f4 mkdocs-redirects==1.2.1 diff --git a/docs/requirements.txt b/docs/requirements.txt index ea93e7d1cae57..01cc0f3d278ed 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ PyYAML==6.0.1 -black==23.10.0 +black==24.3.0 mkdocs==1.5.0 mkdocs-material==9.1.18 mkdocs-redirects==1.2.1