Skip to content

Commit

Permalink
Make mypy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Dec 21, 2024
1 parent 3b89c68 commit 3bee185
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 24 deletions.
6 changes: 3 additions & 3 deletions kitty/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions kitty/file_transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions kitty/fonts/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 1 addition & 6 deletions kitty/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions kitty/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions kitty/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class SingleInstanceData(TypedDict):


class OverlayType(Enum):
transient: str = 'transient'
main: str = 'main'
transient = 'transient'
main = 'main'


class ParsedShortcut(NamedTuple):
Expand Down
8 changes: 4 additions & 4 deletions kitty/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 3bee185

Please sign in to comment.