Skip to content

Commit

Permalink
DRYer
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jan 7, 2025
1 parent 42e0f98 commit d7207ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions kittens/query_terminal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import sys
from binascii import hexlify, unhexlify
from contextlib import suppress
from typing import Dict, Literal, Optional, Type
from typing import Dict, Optional, Type, get_args

from kitty.conf.utils import OSNames, os_name
from kitty.constants import appname, str_version
from kitty.options.types import Options
from kitty.terminfo import names
Expand Down Expand Up @@ -229,11 +230,10 @@ def get_result(opts: Options, window_id: int, os_window_id: int) -> str:
@query
class OSName(Query):
name: str = 'os_name'
help_text: str = 'The name of the OS the terminal is running on. Kitty supports values: linux, macos, bsd or unknown'
help_text: str = f'The name of the OS the terminal is running on. Kitty returns values: {", ".join(sorted(get_args(OSNames)))}'

@staticmethod
def get_result(opts: Options, window_id: int, os_window_id: int) -> Literal['macos', 'bsd', 'linux', 'unknown']:
from kitty.conf.utils import os_name
def get_result(opts: Options, window_id: int, os_window_id: int) -> OSNames:
return os_name()


Expand Down
4 changes: 2 additions & 2 deletions kitty/conf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def set_file(self, file: str) -> Iterator['CurrentlyParsing']:


currently_parsing = CurrentlyParsing()

OSNames = Literal['macos', 'bsd', 'linux', 'unknown']

@run_once
def os_name() -> Literal['macos', 'bsd', 'linux', 'unknown']:
def os_name() -> OSNames:
if is_macos:
return 'macos'
if 'bsd' in _plat:
Expand Down

0 comments on commit d7207ed

Please sign in to comment.