Fix typing issues pointed out by updated mypy
This commit is contained in:
parent
91a714947c
commit
efca2658ea
@ -68,7 +68,10 @@ class Collection:
|
|||||||
self.removed_count += len(lines_for_path(left_path))
|
self.removed_count += len(lines_for_path(left_path))
|
||||||
|
|
||||||
def finalize(self) -> None:
|
def finalize(self) -> None:
|
||||||
self.all_paths.sort(key=path_name_map.get)
|
def key(x: str) -> str:
|
||||||
|
return path_name_map.get(x, '')
|
||||||
|
|
||||||
|
self.all_paths.sort(key=key)
|
||||||
|
|
||||||
def __iter__(self) -> Iterator[Tuple[str, str, Optional[str]]]:
|
def __iter__(self) -> Iterator[Tuple[str, str, Optional[str]]]:
|
||||||
for path in self.all_paths:
|
for path in self.all_paths:
|
||||||
|
|||||||
@ -13,7 +13,9 @@ from collections import defaultdict
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from typing import DefaultDict, Dict, Iterable, List, Optional, Tuple, Union
|
from typing import (
|
||||||
|
Any, DefaultDict, Dict, Iterable, List, Optional, Tuple, Union
|
||||||
|
)
|
||||||
|
|
||||||
from kitty.cli import CONFIG_HELP, parse_args
|
from kitty.cli import CONFIG_HELP, parse_args
|
||||||
from kitty.cli_stub import DiffCLIOptions
|
from kitty.cli_stub import DiffCLIOptions
|
||||||
@ -24,6 +26,11 @@ from kitty.key_encoding import RELEASE, KeyEvent, enter_key, key_defs as K
|
|||||||
from kitty.options_stub import DiffOptions
|
from kitty.options_stub import DiffOptions
|
||||||
from kitty.utils import ScreenSize
|
from kitty.utils import ScreenSize
|
||||||
|
|
||||||
|
from ..tui.handler import Handler
|
||||||
|
from ..tui.images import ImageManager, Placement
|
||||||
|
from ..tui.line_edit import LineEdit
|
||||||
|
from ..tui.loop import Loop
|
||||||
|
from ..tui.operations import styled
|
||||||
from . import global_data
|
from . import global_data
|
||||||
from .collect import (
|
from .collect import (
|
||||||
Collection, create_collection, data_for_path, lines_for_path, sanitize,
|
Collection, create_collection, data_for_path, lines_for_path, sanitize,
|
||||||
@ -35,14 +42,11 @@ from .render import (
|
|||||||
ImagePlacement, ImageSupportWarning, Line, LineRef, Reference, render_diff
|
ImagePlacement, ImageSupportWarning, Line, LineRef, Reference, render_diff
|
||||||
)
|
)
|
||||||
from .search import BadRegex, Search
|
from .search import BadRegex, Search
|
||||||
from ..tui.handler import Handler
|
|
||||||
from ..tui.images import ImageManager, Placement
|
|
||||||
from ..tui.line_edit import LineEdit
|
|
||||||
from ..tui.loop import Loop
|
|
||||||
from ..tui.operations import styled
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .highlight import initialize_highlighter, highlight_collection, DiffHighlight
|
from .highlight import (
|
||||||
|
DiffHighlight, highlight_collection, initialize_highlighter
|
||||||
|
)
|
||||||
has_highlighter = True
|
has_highlighter = True
|
||||||
DiffHighlight
|
DiffHighlight
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -566,8 +570,8 @@ class ShowWarning:
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.warnings: List[str] = []
|
self.warnings: List[str] = []
|
||||||
|
|
||||||
def __call__(self, message: str, category: object, filename: str, lineno: int, file: object = None, line: object = None) -> None:
|
def __call__(self, message: Any, category: Any, filename: str, lineno: int, file: object = None, line: object = None) -> None:
|
||||||
if category is ImageSupportWarning:
|
if category is ImageSupportWarning and isinstance(message, str):
|
||||||
showwarning.warnings.append(message)
|
showwarning.warnings.append(message)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
kitty/key_encoding.py
generated
2
kitty/key_encoding.py
generated
@ -424,7 +424,7 @@ def update_encoding() -> None:
|
|||||||
ans = ENCODING
|
ans = ENCODING
|
||||||
key_map = {}
|
key_map = {}
|
||||||
i = len(ans)
|
i = len(ans)
|
||||||
for k in sorted(keys, key=lambda k: getattr(defines, k)):
|
for k in sorted(keys, key=lambda k: int(getattr(defines, k))):
|
||||||
if k in ('GLFW_KEY_LAST', 'GLFW_KEY_LAST_PRINTABLE'):
|
if k in ('GLFW_KEY_LAST', 'GLFW_KEY_LAST_PRINTABLE'):
|
||||||
continue
|
continue
|
||||||
val = getattr(defines, k)
|
val = getattr(defines, k)
|
||||||
|
|||||||
@ -137,7 +137,7 @@ class ReadFileWithProgressReporting(io.FileIO): # {{{
|
|||||||
def __len__(self) -> int:
|
def __len__(self) -> int:
|
||||||
return self._total
|
return self._total
|
||||||
|
|
||||||
def read(self, size: int = -1) -> Optional[bytes]:
|
def read(self, size: int = -1) -> bytes:
|
||||||
data = io.FileIO.read(self, size)
|
data = io.FileIO.read(self, size)
|
||||||
if data:
|
if data:
|
||||||
self.report_progress(len(data))
|
self.report_progress(len(data))
|
||||||
|
|||||||
2
test.py
2
test.py
@ -97,7 +97,7 @@ def run_tests() -> None:
|
|||||||
|
|
||||||
def run_cli(suite: unittest.TestSuite, verbosity: int = 4) -> None:
|
def run_cli(suite: unittest.TestSuite, verbosity: int = 4) -> None:
|
||||||
r = unittest.TextTestRunner
|
r = unittest.TextTestRunner
|
||||||
r.resultclass = unittest.TextTestResult # type: ignore
|
r.resultclass = unittest.TextTestResult
|
||||||
init_env()
|
init_env()
|
||||||
runner = r(verbosity=verbosity)
|
runner = r(verbosity=verbosity)
|
||||||
runner.tb_locals = True # type: ignore
|
runner.tb_locals = True # type: ignore
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user