mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 23:44:59 +02:00
Replace isort with ruff
This commit is contained in:
@@ -15,9 +15,7 @@ from pty import CHILD, STDIN_FILENO, STDOUT_FILENO, fork
|
||||
from unittest import TestCase
|
||||
|
||||
from kitty.config import finalize_keys, finalize_mouse_mappings
|
||||
from kitty.fast_data_types import (
|
||||
Cursor, HistoryBuf, LineBuf, Screen, get_options, parse_bytes, set_options
|
||||
)
|
||||
from kitty.fast_data_types import Cursor, HistoryBuf, LineBuf, Screen, get_options, parse_bytes, set_options
|
||||
from kitty.options.parse import merge_result_dicts
|
||||
from kitty.options.types import Options, defaults
|
||||
from kitty.types import MouseEvent
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from time import clock_gettime, CLOCK_MONOTONIC, sleep
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
from random import Random
|
||||
from string import printable
|
||||
import sys
|
||||
from time import CLOCK_MONOTONIC, clock_gettime, sleep
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -57,9 +57,7 @@ class TestBuild(BaseTest):
|
||||
self.assertGreater(len(names), 8)
|
||||
|
||||
def test_filesystem_locations(self) -> None:
|
||||
from kitty.constants import (
|
||||
local_docs, logo_png_file, shell_integration_dir, terminfo_dir
|
||||
)
|
||||
from kitty.constants import local_docs, logo_png_file, shell_integration_dir, terminfo_dir
|
||||
zsh = os.path.join(shell_integration_dir, 'zsh')
|
||||
self.assertTrue(os.path.isdir(terminfo_dir), f'Terminfo dir: {terminfo_dir}')
|
||||
self.assertTrue(os.path.exists(logo_png_file), f'Logo file: {logo_png_file}')
|
||||
@@ -113,8 +111,9 @@ class TestBuild(BaseTest):
|
||||
self.ae(docs_url('#ref=issues-123'), 'https://github.com/kovidgoyal/kitty/issues/123')
|
||||
|
||||
def test_launcher_ensures_stdio(self):
|
||||
from kitty.constants import kitty_exe
|
||||
import subprocess
|
||||
|
||||
from kitty.constants import kitty_exe
|
||||
exe = kitty_exe()
|
||||
cp = subprocess.run([exe, '+runpy', f'''\
|
||||
import os, sys
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
from kitty.clipboard import WriteRequest
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
class TestClipboard(BaseTest):
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ from . import BaseTest
|
||||
class TestCrypto(BaseTest):
|
||||
|
||||
def test_elliptic_curve_data_exchange(self):
|
||||
from kitty.fast_data_types import (
|
||||
AES256GCMDecrypt, AES256GCMEncrypt, CryptoError, EllipticCurveKey
|
||||
)
|
||||
from kitty.fast_data_types import AES256GCMDecrypt, AES256GCMEncrypt, CryptoError, EllipticCurveKey
|
||||
alice = EllipticCurveKey()
|
||||
bob = EllipticCurveKey()
|
||||
alice_secret = alice.derive_secret(bob.public)
|
||||
|
||||
@@ -7,10 +7,18 @@ import tempfile
|
||||
|
||||
from kitty.config import build_ansi_color_table, defaults
|
||||
from kitty.fast_data_types import (
|
||||
Color, ColorProfile, Cursor as C, HistoryBuf, LineBuf,
|
||||
parse_input_from_terminal, strip_csi, truncate_point_for_length, wcswidth,
|
||||
wcwidth, expand_ansi_c_escapes
|
||||
Color,
|
||||
ColorProfile,
|
||||
HistoryBuf,
|
||||
LineBuf,
|
||||
expand_ansi_c_escapes,
|
||||
parse_input_from_terminal,
|
||||
strip_csi,
|
||||
truncate_point_for_length,
|
||||
wcswidth,
|
||||
wcwidth,
|
||||
)
|
||||
from kitty.fast_data_types import Cursor as C
|
||||
from kitty.rgb import to_color
|
||||
from kitty.utils import is_path_in_temp_dir, sanitize_title, sanitize_url_for_dispay_to_user
|
||||
|
||||
@@ -538,9 +546,7 @@ class TestDataTypes(BaseTest):
|
||||
q('a\x1b[12;34:43mbc', 'abc')
|
||||
|
||||
def test_single_key(self):
|
||||
from kitty.fast_data_types import (
|
||||
GLFW_MOD_KITTY, GLFW_MOD_SHIFT, SingleKey
|
||||
)
|
||||
from kitty.fast_data_types import GLFW_MOD_KITTY, GLFW_MOD_SHIFT, SingleKey
|
||||
for m in (GLFW_MOD_KITTY, GLFW_MOD_SHIFT):
|
||||
s = SingleKey(mods=m)
|
||||
self.ae(s.mods, m)
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestDiff(BaseTest):
|
||||
self.assertEqual((prefix, suffix), (src[:pc], src[-sc:] if sc else ''))
|
||||
|
||||
def test_split_with_highlights(self):
|
||||
from kittens.diff.render import split_with_highlights, Segment, truncate_points
|
||||
from kittens.diff.render import Segment, split_with_highlights, truncate_points
|
||||
self.ae(list(truncate_points('1234567890ab', 3)), [3, 6, 9])
|
||||
for line, width, prefix_count, suffix_count, expected in [
|
||||
('abcdefgh', 20, 2, 3, ('abSScdeEEfgh',)),
|
||||
@@ -45,8 +45,9 @@ class TestDiff(BaseTest):
|
||||
self.ae(['S1SaE1ES2SbcE2Ed'], split_with_highlights('abcd', 10, highlights))
|
||||
|
||||
def test_walk(self):
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from kittens.diff.collect import walk
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
@@ -9,19 +9,14 @@ import tempfile
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
from kittens.transfer.librsync import (
|
||||
LoadSignature, PatchFile, delta_for_file, signature_of_file
|
||||
)
|
||||
from kittens.transfer.librsync import LoadSignature, PatchFile, delta_for_file, signature_of_file
|
||||
from kittens.transfer.main import parse_transfer_args
|
||||
from kittens.transfer.receive import File, files_for_receive
|
||||
from kittens.transfer.rsync import decode_utf8_buffer, parse_ftc
|
||||
from kittens.transfer.send import files_for_send
|
||||
from kittens.transfer.utils import cwd_path, expand_home, home_path, set_paths
|
||||
from kitty.file_transmission import (
|
||||
Action, Compression, FileTransmissionCommand, FileType,
|
||||
TestFileTransmission as FileTransmission, TransmissionType,
|
||||
ZlibDecompressor, iter_file_metadata
|
||||
)
|
||||
from kitty.file_transmission import Action, Compression, FileTransmissionCommand, FileType, TransmissionType, ZlibDecompressor, iter_file_metadata
|
||||
from kitty.file_transmission import TestFileTransmission as FileTransmission
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@@ -9,14 +9,9 @@ import unittest
|
||||
from functools import partial
|
||||
|
||||
from kitty.constants import is_macos, read_kitty_resource
|
||||
from kitty.fast_data_types import (
|
||||
DECAWM, get_fallback_font, sprite_map_set_layout, sprite_map_set_limits,
|
||||
test_render_line, test_sprite_position_for, wcwidth
|
||||
)
|
||||
from kitty.fast_data_types import DECAWM, get_fallback_font, sprite_map_set_layout, sprite_map_set_limits, test_render_line, test_sprite_position_for, wcwidth
|
||||
from kitty.fonts.box_drawing import box_chars
|
||||
from kitty.fonts.render import (
|
||||
coalesce_symbol_maps, render_string, setup_for_testing, shape_string
|
||||
)
|
||||
from kitty.fonts.render import coalesce_symbol_maps, render_string, setup_for_testing, shape_string
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
_plat = sys.platform.lower()
|
||||
@@ -42,6 +43,7 @@ class TestGLFW(BaseTest):
|
||||
@unittest.skipIf(is_macos, 'Skipping test on macOS because glfw-cocoa.so is not built with backend_utils')
|
||||
def test_utf_8_strndup(self):
|
||||
import ctypes
|
||||
|
||||
from kitty.constants import glfw_path
|
||||
|
||||
backend_utils = glfw_path('x11')
|
||||
|
||||
@@ -12,9 +12,7 @@ from dataclasses import dataclass
|
||||
from io import BytesIO
|
||||
from itertools import cycle
|
||||
|
||||
from kitty.fast_data_types import (
|
||||
load_png_data, parse_bytes, shm_unlink, shm_write, xor_data
|
||||
)
|
||||
from kitty.fast_data_types import load_png_data, parse_bytes, shm_unlink, shm_write, xor_data
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@@ -2,16 +2,14 @@
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
class TestHints(BaseTest):
|
||||
|
||||
def test_url_hints(self):
|
||||
from kittens.hints.main import (
|
||||
Mark, convert_text, functions_for, linenum_marks,
|
||||
linenum_process_result, mark, parse_hints_args, process_escape_codes
|
||||
)
|
||||
from kittens.hints.main import Mark, convert_text, functions_for, linenum_marks, linenum_process_result, mark, parse_hints_args, process_escape_codes
|
||||
args = parse_hints_args([])[0]
|
||||
pattern, post_processors = functions_for(args)
|
||||
|
||||
@@ -54,9 +52,7 @@ class TestHints(BaseTest):
|
||||
m('~/file.c:23:32', os.path.expanduser('~/file.c'), 23)
|
||||
|
||||
def test_ip_hints(self):
|
||||
from kittens.hints.main import (
|
||||
convert_text, functions_for, mark, parse_hints_args
|
||||
)
|
||||
from kittens.hints.main import convert_text, functions_for, mark, parse_hints_args
|
||||
args = parse_hints_args(['--type', 'ip'])[0]
|
||||
pattern, post_processors = functions_for(args)
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
from functools import partial
|
||||
|
||||
import kitty.fast_data_types as defines
|
||||
from kitty.key_encoding import (
|
||||
EventType, KeyEvent, decode_key_event, encode_key_event
|
||||
)
|
||||
from kitty.key_encoding import EventType, KeyEvent, decode_key_event, encode_key_event
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from kitty.config import defaults
|
||||
from kitty.types import WindowGeometry
|
||||
from kitty.layout.interface import Grid, Horizontal, Splits, Stack, Tall
|
||||
from kitty.types import WindowGeometry
|
||||
from kitty.window import EdgeWidths
|
||||
from kitty.window_list import WindowList, reset_group_id_counter
|
||||
|
||||
|
||||
@@ -13,7 +13,16 @@ from contextlib import contextmanager
|
||||
from functools import lru_cache
|
||||
from tempfile import TemporaryDirectory
|
||||
from typing import (
|
||||
Any, Callable, Dict, Generator, Iterator, List, NoReturn, Optional, Sequence, Set,
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
Iterator,
|
||||
List,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
Tuple,
|
||||
)
|
||||
|
||||
|
||||
@@ -4,9 +4,13 @@
|
||||
from functools import partial
|
||||
|
||||
from kitty.fast_data_types import (
|
||||
GLFW_MOD_ALT, GLFW_MOD_CONTROL, GLFW_MOUSE_BUTTON_LEFT,
|
||||
GLFW_MOUSE_BUTTON_RIGHT, create_mock_window, mock_mouse_selection,
|
||||
send_mock_mouse_event_to_window
|
||||
GLFW_MOD_ALT,
|
||||
GLFW_MOD_CONTROL,
|
||||
GLFW_MOUSE_BUTTON_LEFT,
|
||||
GLFW_MOUSE_BUTTON_RIGHT,
|
||||
create_mock_window,
|
||||
mock_mouse_selection,
|
||||
send_mock_mouse_event_to_window,
|
||||
)
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
|
||||
from . import BaseTest
|
||||
from kitty.utils import get_editor
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_env(**kw):
|
||||
@@ -25,7 +26,7 @@ def patch_env(**kw):
|
||||
class TestOpenActions(BaseTest):
|
||||
|
||||
def test_parsing_of_open_actions(self):
|
||||
from kitty.open_actions import actions_for_url, KeyAction
|
||||
from kitty.open_actions import KeyAction, actions_for_url
|
||||
self.set_options()
|
||||
spec = '''
|
||||
protocol file
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
from . import BaseTest
|
||||
from kitty.utils import log_error
|
||||
from kitty.options.utils import DELETE_ENV_VAR
|
||||
from kitty.fast_data_types import Color
|
||||
from kitty.options.utils import DELETE_ENV_VAR
|
||||
from kitty.utils import log_error
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
class TestConfParsing(BaseTest):
|
||||
@@ -20,10 +21,10 @@ class TestConfParsing(BaseTest):
|
||||
super().tearDown()
|
||||
|
||||
def test_conf_parsing(self):
|
||||
from kitty.config import load_config, defaults
|
||||
from kitty.config import defaults, load_config
|
||||
from kitty.constants import is_macos
|
||||
from kitty.fonts import FontModification, ModificationType, ModificationUnit, ModificationValue
|
||||
from kitty.options.utils import to_modifiers
|
||||
from kitty.fonts import FontModification, ModificationType, ModificationValue, ModificationUnit
|
||||
bad_lines = []
|
||||
|
||||
def p(*lines, bad_line_num=0):
|
||||
|
||||
@@ -7,10 +7,7 @@ from binascii import hexlify
|
||||
from functools import partial
|
||||
|
||||
from kitty.fast_data_types import CURSOR_BLOCK, parse_bytes, parse_bytes_dump
|
||||
from kitty.notify import (
|
||||
NotificationCommand, handle_notification_cmd, notification_activated,
|
||||
reset_registry
|
||||
)
|
||||
from kitty.notify import NotificationCommand, handle_notification_cmd, notification_activated, reset_registry
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@@ -11,10 +11,7 @@ import tempfile
|
||||
import time
|
||||
|
||||
from kitty.constants import kitty_exe
|
||||
from kitty.fast_data_types import (
|
||||
CLD_EXITED, CLD_KILLED, CLD_STOPPED, get_options, has_sigqueue, install_signal_handlers,
|
||||
read_signals, sigqueue
|
||||
)
|
||||
from kitty.fast_data_types import CLD_EXITED, CLD_KILLED, CLD_STOPPED, get_options, has_sigqueue, install_signal_handlers, read_signals, sigqueue
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from kitty.fast_data_types import (
|
||||
DECAWM, DECCOLM, DECOM, IRM, Cursor, parse_bytes
|
||||
)
|
||||
from kitty.fast_data_types import DECAWM, DECCOLM, DECOM, IRM, Cursor, parse_bytes
|
||||
from kitty.marks import marker_from_function, marker_from_regex
|
||||
from kitty.window import pagerhist
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from . import BaseTest
|
||||
class TestSQP(BaseTest):
|
||||
|
||||
def test_search_query_parser(self):
|
||||
from kitty.search_query_parser import search, ParseException
|
||||
from kitty.search_query_parser import ParseException, search
|
||||
locations = 'id'
|
||||
universal_set = {1, 2, 3, 4, 5}
|
||||
|
||||
|
||||
@@ -11,12 +11,10 @@ import unittest
|
||||
from contextlib import contextmanager
|
||||
from functools import lru_cache, partial
|
||||
|
||||
from kitty.constants import kitty_base_dir, terminfo_dir, shell_integration_dir
|
||||
from kitty.fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE
|
||||
from kitty.shell_integration import (
|
||||
setup_bash_env, setup_fish_env, setup_zsh_env
|
||||
)
|
||||
from kitty.bash import decode_ansi_c_quoted_string
|
||||
from kitty.constants import kitty_base_dir, shell_integration_dir, terminfo_dir
|
||||
from kitty.fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE
|
||||
from kitty.shell_integration import setup_bash_env, setup_fish_env, setup_zsh_env
|
||||
|
||||
from . import BaseTest
|
||||
|
||||
|
||||
@@ -6,13 +6,11 @@ import glob
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from functools import lru_cache
|
||||
from contextlib import suppress
|
||||
from functools import lru_cache
|
||||
|
||||
from kittens.ssh.config import load_config
|
||||
from kittens.ssh.main import (
|
||||
bootstrap_script, get_connection_data, wrap_bootstrap_script
|
||||
)
|
||||
from kittens.ssh.main import bootstrap_script, get_connection_data, wrap_bootstrap_script
|
||||
from kittens.ssh.options.types import Options as SSHOptions
|
||||
from kittens.ssh.options.utils import DELETE_ENV_VAR
|
||||
from kittens.transfer.utils import set_paths
|
||||
|
||||
Reference in New Issue
Block a user