From 3bee1857f73c170f2746cc9e9b75aa715204045d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 21 Dec 2024 08:06:29 +0530 Subject: [PATCH] Make mypy happy --- kitty/colors.py | 6 +++--- kitty/file_transmission.py | 4 ++-- kitty/fonts/features.py | 6 +++--- kitty/launch.py | 7 +------ kitty/notifications.py | 6 +++--- kitty/types.py | 4 ++-- kitty/window.py | 8 ++++---- publish.py | 2 +- 8 files changed, 19 insertions(+), 24 deletions(-) diff --git a/kitty/colors.py b/kitty/colors.py index 0816ca0a9..7c57884c3 100644 --- a/kitty/colors.py +++ b/kitty/colors.py @@ -20,9 +20,9 @@ class ThemeFile(Enum): - dark: str = 'dark-theme.auto.conf' - light: str = 'light-theme.auto.conf' - no_preference: str = 'no-preference-theme.auto.conf' + dark = 'dark-theme.auto.conf' + light = 'light-theme.auto.conf' + no_preference = 'no-preference-theme.auto.conf' class ThemeColors: diff --git a/kitty/file_transmission.py b/kitty/file_transmission.py index 05c9bf12c..4a2399276 100644 --- a/kitty/file_transmission.py +++ b/kitty/file_transmission.py @@ -118,7 +118,7 @@ def add_dir(ftc: FileTransmissionCommand) -> None: sr = os.stat(path, follow_symlinks=False) read_ok = os.access(path, os.R_OK, follow_symlinks=False) except OSError as err: - errname = errno.errorcode.get(err.errno, 'EFAIL') + errname = errno.errorcode.get(err.errno, 'EFAIL') if err.errno is not None else 'EFAIL' yield TransmissionError(file_id=spec_id, code=errname, msg='Failed to read spec') continue if not read_ok: @@ -1222,7 +1222,7 @@ def handle_send_confirmation(self, confirmed: bool, cmd_id: str) -> None: def send_fail_on_os_error(self, err: OSError, msg: str, ar: Union[ActiveSend, ActiveReceive], file_id: str = '') -> None: if not ar.send_errors: return - errname = errno.errorcode.get(err.errno, 'EFAIL') + errname = errno.errorcode.get(err.errno, 'EFAIL') if err.errno is not None else 'EFAIL' self.send_status_response(code=errname, msg=msg, request_id=ar.id, file_id=file_id) def active_file(self, rid: str = '', file_id: str = '') -> DestFile: diff --git a/kitty/fonts/features.py b/kitty/fonts/features.py index 0b244cedf..9ea5cc819 100644 --- a/kitty/fonts/features.py +++ b/kitty/fonts/features.py @@ -6,9 +6,9 @@ class Type(IntEnum): - boolean: int = 1 - index: int = 2 - hidden: int = 3 + boolean = 1 + index = 2 + hidden = 3 class FeatureDefinition(NamedTuple): diff --git a/kitty/launch.py b/kitty/launch.py index 2b2ee594e..9dd7960b2 100644 --- a/kitty/launch.py +++ b/kitty/launch.py @@ -6,7 +6,7 @@ import shutil from collections.abc import Container, Iterable, Iterator, Sequence from contextlib import suppress -from typing import Any, NamedTuple, Optional +from typing import Any, NamedTuple, Optional, TypedDict from .boss import Boss from .child import Child @@ -20,11 +20,6 @@ from .utils import get_editor, log_error, resolve_custom_file, which from .window import CwdRequest, CwdRequestType, Watchers, Window -try: - from typing import TypedDict -except ImportError: - TypedDict = dict - class LaunchSpec(NamedTuple): opts: LaunchCLIOptions diff --git a/kitty/notifications.py b/kitty/notifications.py index 3efc7826e..0ceac0f0a 100644 --- a/kitty/notifications.py +++ b/kitty/notifications.py @@ -118,9 +118,9 @@ def remove_icon(self, key: str) -> None: class Urgency(Enum): - Low: int = 0 - Normal: int = 1 - Critical: int = 2 + Low = 0 + Normal = 1 + Critical = 2 class PayloadType(Enum): diff --git a/kitty/types.py b/kitty/types.py index 16f908f8b..eb7891f94 100644 --- a/kitty/types.py +++ b/kitty/types.py @@ -23,8 +23,8 @@ class SingleInstanceData(TypedDict): class OverlayType(Enum): - transient: str = 'transient' - main: str = 'main' + transient = 'transient' + main = 'main' class ParsedShortcut(NamedTuple): diff --git a/kitty/window.py b/kitty/window.py index f8da6527e..658d1fa42 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -123,10 +123,10 @@ class CwdRequestType(Enum): - current: int = auto() - last_reported: int = auto() - oldest: int = auto() - root: int = auto() + current = auto() + last_reported = auto() + oldest = auto() + root = auto() class CwdRequest: diff --git a/publish.py b/publish.py index 507a82b76..aac099c1a 100755 --- a/publish.py +++ b/publish.py @@ -209,7 +209,7 @@ def __init__(self, path: str): def __len__(self) -> int: return self._total - def read(self, size: int = -1) -> bytes: + def read(self, size: Optional[int] = -1) -> bytes: data = io.FileIO.read(self, size) if data: self.report_progress(len(data))