From 3e8a1ac7d6cea3ef95de98089d6494cb61055f1e Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Tue, 29 Aug 2023 15:21:06 -0300 Subject: [PATCH] bump ruff to 0.0.285 --- craft_cli/dispatcher.py | 3 +-- craft_cli/errors.py | 4 ++-- craft_cli/helptexts.py | 6 ++---- craft_cli/messages.py | 10 ++++++---- craft_cli/printer.py | 4 ++-- pyproject.toml | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/craft_cli/dispatcher.py b/craft_cli/dispatcher.py index 4af980e..9e779d0 100644 --- a/craft_cli/dispatcher.py +++ b/craft_cli/dispatcher.py @@ -337,8 +337,7 @@ def _get_requested_help( # noqa: PLR0912 (too many branches) dest = action.metavar command_options.append((dest, help_text)) - help_text = self._help_builder.get_command_help(command, command_options, output_format) - return help_text + return self._help_builder.get_command_help(command, command_options, output_format) def _build_no_command_error(self, missing_command: str) -> str: """Build the error help text for missing command, providing options.""" diff --git a/craft_cli/errors.py b/craft_cli/errors.py index 475abca..77c43ac 100644 --- a/craft_cli/errors.py +++ b/craft_cli/errors.py @@ -20,7 +20,7 @@ "CraftError", ] -from typing import Any, Optional +from typing import Optional class CraftError(Exception): @@ -71,7 +71,7 @@ def __init__( # noqa: PLR0913 (too many arguments) self.reportable = reportable self.retcode = retcode - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: if isinstance(other, CraftError): return all( [ diff --git a/craft_cli/helptexts.py b/craft_cli/helptexts.py index 74d1423..99bf99b 100644 --- a/craft_cli/helptexts.py +++ b/craft_cli/helptexts.py @@ -212,8 +212,7 @@ def get_full_help(self, global_options: list[tuple[str, str]]) -> str: ) # join all stripped blocks, leaving ONE empty blank line between - text = "\n\n".join(block.strip() for block in textblocks) + "\n" - return text + return "\n\n".join(block.strip() for block in textblocks) + "\n" def get_detailed_help(self, global_options: list[tuple[str, str]]) -> str: """Produce the text for the detailed help. @@ -270,8 +269,7 @@ def get_detailed_help(self, global_options: list[tuple[str, str]]) -> str: ) # join all stripped blocks, leaving ONE empty blank line between - text = "\n\n".join(block.strip() for block in textblocks) + "\n" - return text + return "\n\n".join(block.strip() for block in textblocks) + "\n" def _build_plain_command_help( self, diff --git a/craft_cli/messages.py b/craft_cli/messages.py index 79da977..af0a8b3 100644 --- a/craft_cli/messages.py +++ b/craft_cli/messages.py @@ -49,6 +49,8 @@ if TYPE_CHECKING: from types import TracebackType + from typing_extensions import Self + from craft_cli import errors @@ -114,7 +116,7 @@ class _Progresser: def __init__( # noqa: PLR0913 (too many arguments) self, printer: Printer, - total: int | float, + total: float, text: str, stream: TextIO | None, delta: bool, # noqa: FBT001 (boolean positional arg) @@ -133,7 +135,7 @@ def __init__( # noqa: PLR0913 (too many arguments) # is always ephemeral self.ephemeral_context = ephemeral_context - def __enter__(self) -> _Progresser: + def __enter__(self) -> Self: text = f"{self.text} (--->)" self.printer.show( self.stream, text, ephemeral=self.ephemeral_context, use_timestamp=self.use_timestamp @@ -152,7 +154,7 @@ def __exit__( ) return False # do not consume any exception - def advance(self, amount: int | float) -> None: + def advance(self, amount: float) -> None: """Show a progress bar according to the informed advance.""" if amount < 0: raise ValueError("The advance amount cannot be negative") @@ -625,7 +627,7 @@ def progress(self, text: str, permanent: bool = False) -> None: # noqa: FBT001, @_active_guard() def progress_bar( - self, text: str, total: int | float, delta: bool = True # noqa: FBT001, FBT002 + self, text: str, total: float, delta: bool = True # noqa: FBT001, FBT002 ) -> _Progresser: """Progress information for a potentially long-running single step of a command. diff --git a/craft_cli/printer.py b/craft_cli/printer.py index c816c83..3008bdf 100644 --- a/craft_cli/printer.py +++ b/craft_cli/printer.py @@ -376,8 +376,8 @@ def progress_bar( # noqa: PLR0913 stream: TextIO | None, text: str, *, - progress: int | float, - total: int | float, + progress: float, + total: float, use_timestamp: bool, ) -> None: """Show a progress bar to the given stream.""" diff --git a/pyproject.toml b/pyproject.toml index 5aecfd4..b1e21d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ dev = [ lint = [ "black==23.7.0", "codespell[toml]==2.2.5", - "ruff==0.0.269", + "ruff==0.0.285", "yamllint==1.32.0" ] types = [