From 9d8ff015c6c25b2e22b265bec1c5857142a0ed1b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 May 2024 07:27:43 -0400 Subject: [PATCH 1/2] Perform releases only within the 'release' environment this is recommended by pypi for trusted publishers --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c9b446..30ad226 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,7 @@ jobs: release: runs-on: ubuntu-22.04 + environment: release permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write From b42a8c08cd7972ab91abd2ec51d36a29677958eb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 May 2024 07:30:33 -0400 Subject: [PATCH 2/2] ESC and F9 clear any in-progress search --- src/ttotp/__main__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ttotp/__main__.py b/src/ttotp/__main__.py index 568e721..58decee 100755 --- a/src/ttotp/__main__.py +++ b/src/ttotp/__main__.py @@ -30,6 +30,10 @@ import pyotp import platformdirs import tomllib +from textual._ansi_sequences import ANSI_SEQUENCES_KEYS +from textual.keys import Keys +from typing import TypeGuard # use `typing_extensions` for Python 3.9 and below + # workaround for pyperclip being un-typed if TYPE_CHECKING: @@ -42,8 +46,6 @@ else: from pyperclip import paste as pyperclip_paste from pyperclip import copy as pyperclip_copy -from typing import TypeGuard # use `typing_extensions` for Python 3.9 and below - def is_str_list(val: Any) -> TypeGuard[list[str]]: """Determines whether all objects in the list are strings""" @@ -52,6 +54,12 @@ def is_str_list(val: Any) -> TypeGuard[list[str]]: return all(isinstance(x, str) for x in val) +# Monkeypatch escape key as meaning "F9", WFM +# ignore typing here because ANSI_SEQUENCES_KEYS is a Mapping[] which is read-only as +# far as mypy is concerned. +ANSI_SEQUENCES_KEYS["\x1b\x1b"] = (Keys.F9,) # type: ignore + + # Copied from pyotp with the issuer mismatch check removed and HTOP support removed def parse_uri(uri: str) -> pyotp.TOTP: """ @@ -176,6 +184,7 @@ class SearchInput(Input, can_focus=False): Binding("up", "focus_previous", show=False), Binding("down", "focus_next", show=False), Binding("ctrl+a", "clear_search", "Show all", show=True), + Binding("F9", "clear_search", show=True), ] def on_focus(self) -> None: