Make latest version of ty happy
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run

This commit is contained in:
Kovid Goyal 2026-07-13 08:13:08 +05:30
parent 7ab90de166
commit 0bf176be5c
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 7 deletions

View file

@ -2,7 +2,7 @@
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import inspect
from typing import NamedTuple, cast
from typing import Any, NamedTuple
from .boss import Boss
from .tabs import Tab
@ -39,18 +39,19 @@ def get_all_actions() -> dict[ActionGroup, list[Action]]:
ans: dict[ActionGroup, list[Action]] = {}
def is_action(x: object) -> bool:
def is_action(x: Any) -> bool:
return isinstance(getattr(x, 'action_spec', None), ActionSpec)
def as_action(x: object) -> Action:
def as_action(x: Any) -> Action:
spec: ActionSpec = getattr(x, 'action_spec')
doc = inspect.cleandoc(spec.doc)
lines = doc.splitlines()
first = lines.pop(0)
short_help = first
long_help = '\n'.join(lines).strip()
assert spec.group in groups
return Action(getattr(x, '__name__'), cast(ActionGroup, spec.group), short_help, long_help)
if spec.group not in groups:
raise KeyError(f'Unknown action type: {spec.group}')
return Action(getattr(x, '__name__'), spec.group, short_help, long_help)
seen = set()
for cls in (Window, Tab, Boss):

View file

@ -7,7 +7,7 @@ import posixpath
import shlex
from collections.abc import Iterable, Iterator
from contextlib import suppress
from typing import Any, NamedTuple, cast
from typing import Any, NamedTuple
from urllib.parse import ParseResult, unquote, urlparse
from .conf.utils import KeyAction, to_cmdline_implementation
@ -56,7 +56,7 @@ def parse(lines: Iterable[str]) -> Iterator[OpenAction]:
elif key in ('mime', 'ext', 'protocol', 'file', 'path', 'url', 'fragment_matches'):
if key != 'url':
rest = rest.lower()
match_criteria.append(MatchCriteria(cast(MatchType, key), rest))
match_criteria.append(MatchCriteria(key, rest))
elif key == 'action_alias':
try:
alias_name, alias_val = rest.split(maxsplit=1)