From 069c33bc178bb161af087870923492fdbad16a07 Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Thu, 16 Jul 2026 21:48:28 -0300 Subject: [PATCH] style: run black formatter --- src/git_flow/command/base.py | 62 +++++++++++++++++++++++++++------- src/git_flow/command/commit.py | 4 ++- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/git_flow/command/base.py b/src/git_flow/command/base.py index 342cc33..74aa804 100644 --- a/src/git_flow/command/base.py +++ b/src/git_flow/command/base.py @@ -18,9 +18,11 @@ import rich import rich.panel import questionary - flowconfig = Git.get_config(FLOWCONFIG_FILENAME) if isfile(FLOWCONFIG_FILENAME) else {} -environments = flowconfig["flow.branches"].split(",") if "flow.branches" in flowconfig else [] +environments = ( + flowconfig["flow.branches"].split(",") if "flow.branches" in flowconfig else [] +) + def ensure_initialized(): initialized = flowconfig["flow.initialized"] if flowconfig else None @@ -118,7 +120,8 @@ def get_remote_api(token: str) -> RemoteAPI: [schema, host, repository] = RemoteAPI.parse(flowconfig["flow.remote"]) if remote_type == "gitea": - return GiteaRemoteAPI(("https://" if schema == "ssh://" else schema) + host, repository, token) + remote_schema = "https://" if schema == "ssh://" else schema + return GiteaRemoteAPI(remote_schema + host, repository, token) elif remote_type == "bitbucket": return BitbucketRemoteAPI(repository, token) elif remote_type == "github": @@ -133,40 +136,75 @@ def is_valid_ticket(ticket: str) -> bool: if len(components) != 2: return False - + ticket_project = components[0] ticket_number = components[1] - return ticket_project.isalpha() and ticket_project.isupper() and ticket_number.isnumeric() + return ( + ticket_project.isalpha() + and ticket_project.isupper() + and ticket_number.isnumeric() + ) + def io_error(message: str, title: Optional[str] = None): _io_status(message, "✖ Error: ", "red", title) + def io_warning(message: str, title: Optional[str] = None): _io_status(message, "⚠ Warning: ", "yellow", title) + def io_info(message: str, title: Optional[str] = None): _io_status(message, "ℹ Info: ", "blue", title) + def io_success(message: str, title: Optional[str] = None): _io_status(message, "✔ Success: ", "green", title) + def _io_status(message: str, prefix: str, style: str, title: Optional[str] = None): if title: - rich.print(rich.panel.Panel(message, title=prefix + title, style=style, expand=False, title_align="left")) + rich.print( + rich.panel.Panel( + message, + title=prefix + title, + style=style, + expand=False, + title_align="left", + ) + ) else: rich.print(f"[{style}]{prefix}{message}[/{style}]") - + + def io_confirm(question: str, default: bool = True) -> bool: return questionary.confirm(question, default=default, auto_enter=False).ask() -def io_choice(prompt: str, options: list[str]) -> str: - return questionary.select(prompt, options, use_search_filter=True, use_jk_keys=False, instruction="Tipear o usar flechas").ask() -def io_prompt(message: str, default: str = "", persistent: bool = False, strip: bool = False, validator = None, instruction: str | None = None) -> str: +def io_choice(prompt: str, options: list[str]) -> str: + return questionary.select( + prompt, + options, + use_search_filter=True, + use_jk_keys=False, + instruction="Tipear o usar flechas", + ).ask() + + +def io_prompt( + message: str, + default: str = "", + persistent: bool = False, + strip: bool = False, + validator=None, + instruction: str | None = None, +) -> str: if persistent and not validator: validator = lambda s: len(s.strip()) > 0 - value = questionary.text(message, default, validate=validator, instruction=instruction).ask() + value = questionary.text( + message, default, validate=validator, instruction=instruction + ).ask() - return value.strip() if strip else value \ No newline at end of file + return value.strip() if strip else value diff --git a/src/git_flow/command/commit.py b/src/git_flow/command/commit.py index 79ae2c6..54017c2 100644 --- a/src/git_flow/command/commit.py +++ b/src/git_flow/command/commit.py @@ -22,7 +22,9 @@ def commit(): commit_type = base.io_choice("Tipo de commit", COMMIT_TYPES) commit_message = base.io_prompt( - "Mensaje (máximo recomendado: 100 caracteres)", persistent=True + "Mensaje de commit", + validator=lambda s: 0 < len(s) and len(s) < 100, + instruction="100 caracteres máximo" ) message = commit_type + ": " + commit_message