Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency black to v24 #12728

Merged
merged 3 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ 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():
/// await long_running_task(timeout=2)
/// ```
///
/// Use instead:
///
/// ```python
/// async def long_running_task():
/// ...
/// async def long_running_task(): ...
///
///
/// async def main():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -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
///
Expand All @@ -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
///
Expand All @@ -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
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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:
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading