Make mypy happy

This commit is contained in:
Kovid Goyal
2024-12-21 08:06:29 +05:30
parent 3b89c686e6
commit 3bee1857f7
8 changed files with 19 additions and 24 deletions

View File

@@ -20,9 +20,9 @@ Colors = tuple[ColorsSpec, TransparentBackgroundColors]
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:

View File

@@ -118,7 +118,7 @@ def iter_file_metadata(file_specs: Iterable[tuple[str, str]]) -> Iterator[Union[
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 @@ class FileTransmission:
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:

View File

@@ -6,9 +6,9 @@ from typing import NamedTuple
class Type(IntEnum):
boolean: int = 1
index: int = 2
hidden: int = 3
boolean = 1
index = 2
hidden = 3
class FeatureDefinition(NamedTuple):

View File

@@ -6,7 +6,7 @@ import os
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 .types import OverlayType, run_once
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

View File

@@ -118,9 +118,9 @@ class IconDataCache:
class Urgency(Enum):
Low: int = 0
Normal: int = 1
Critical: int = 2
Low = 0
Normal = 1
Critical = 2
class PayloadType(Enum):

View File

@@ -23,8 +23,8 @@ class SingleInstanceData(TypedDict):
class OverlayType(Enum):
transient: str = 'transient'
main: str = 'main'
transient = 'transient'
main = 'main'
class ParsedShortcut(NamedTuple):

View File

@@ -123,10 +123,10 @@ if TYPE_CHECKING:
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:

View File

@@ -209,7 +209,7 @@ class ReadFileWithProgressReporting(io.FileIO): # {{{
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))