More pyugrade to 3.9

This commit is contained in:
Kovid Goyal
2024-08-05 10:59:50 +05:30
parent a35f7e060b
commit 2b3f2258ff
12 changed files with 88 additions and 110 deletions

View File

@@ -592,7 +592,7 @@ class TestDataTypes(BaseTest):
for x in ('\x1b[201~ab\x9b201~cd', '\x1b[201\x1b[201~~ab'): # ]]]
q = sanitize_for_bracketed_paste(x.encode('utf-8'))
self.assertNotIn(b'\x1b[201~', q)
self.assertNotIn('\x9b201~'.encode('utf-8'), q)
self.assertNotIn('\x9b201~'.encode(), q)
self.assertIn(b'ab', q)
def test_expand_ansi_c_escapes(self):

View File

@@ -9,6 +9,7 @@ import subprocess
import sys
import time
import unittest
from collections.abc import Generator, Iterator, Sequence
from contextlib import contextmanager
from functools import lru_cache
from tempfile import TemporaryDirectory
@@ -16,15 +17,8 @@ from threading import Thread
from typing import (
Any,
Callable,
Dict,
Generator,
Iterator,
List,
NoReturn,
Optional,
Sequence,
Set,
Tuple,
)
from . import BaseTest
@@ -68,7 +62,7 @@ def find_all_tests(package: str = '', excludes: Sequence[str] = ('main', 'gr'))
def filter_tests(suite: unittest.TestSuite, test_ok: Callable[[unittest.TestCase], bool]) -> unittest.TestSuite:
ans = unittest.TestSuite()
added: Set[unittest.TestCase] = set()
added: set[unittest.TestCase] = set()
for test in itertests(suite):
if test_ok(test) and test not in added:
ans.addTest(test)
@@ -124,8 +118,8 @@ def run_cli(suite: unittest.TestSuite, verbosity: int = 4) -> bool:
return result.wasSuccessful()
def find_testable_go_packages() -> Tuple[Set[str], Dict[str, List[str]]]:
test_functions: Dict[str, List[str]] = {}
def find_testable_go_packages() -> tuple[set[str], dict[str, list[str]]]:
test_functions: dict[str, list[str]] = {}
ans = set()
base = os.getcwd()
pat = re.compile(r'^func Test([A-Z]\w+)', re.MULTILINE)
@@ -148,7 +142,7 @@ def go_exe() -> str:
class GoProc(Thread):
def __init__(self, cmd: List[str]):
def __init__(self, cmd: list[str]):
super().__init__(name='GoProc')
from kitty.constants import kitty_exe
env = os.environ.copy()
@@ -182,7 +176,7 @@ class GoProc(Thread):
return self.stdout.decode('utf-8', 'replace'), self.proc.returncode
def run_go(packages: Set[str], names: str) -> GoProc:
def run_go(packages: set[str], names: str) -> GoProc:
go = go_exe()
go_pkg_args = [f'kitty/{x}' for x in packages]
cmd = [go, 'test', '-v']
@@ -193,7 +187,7 @@ def run_go(packages: Set[str], names: str) -> GoProc:
def reduce_go_pkgs(module: str, names: Sequence[str]) -> Set[str]:
def reduce_go_pkgs(module: str, names: Sequence[str]) -> set[str]:
if not go_exe():
raise SystemExit('go executable not found, current path: ' + repr(os.environ.get('PATH', '')))
go_packages, go_functions = find_testable_go_packages()

View File

@@ -19,7 +19,7 @@ from kitty.shell_integration import setup_bash_env, setup_fish_env, setup_zsh_en
from . import BaseTest
@lru_cache()
@lru_cache
def bash_ok():
v = shutil.which('bash')
if not v:

View File

@@ -46,7 +46,7 @@ print(' '.join(map(str, buf)))'''), lines=13, cols=77)
def t(cmdline, binary='ssh', host='main', port=None, identity_file='', extra_args=()):
if identity_file:
identity_file = os.path.abspath(identity_file)
en = set(f'{x[0]}' for x in extra_args)
en = {f'{x[0]}' for x in extra_args}
q = get_connection_data(cmdline.split(), extra_args=en)
self.ae(q, SSHConnectionData(binary, host, port, identity_file, extra_args))
@@ -59,7 +59,7 @@ print(' '.join(map(str, buf)))'''), lines=13, cols=77)
self.assertTrue(runtime_dir())
@property
@lru_cache()
@lru_cache
def all_possible_sh(self):
python = 'python3' if shutil.which('python3') else 'python'
return tuple(filter(shutil.which, ('dash', 'zsh', 'bash', 'posh', 'sh', python)))
@@ -102,7 +102,7 @@ copy --exclude **/w.* --exclude **/r d1
self.assertTrue(os.path.exists(f'{remote_home}/{tname}/78/xterm-kitty'))
self.assertTrue(os.path.exists(f'{remote_home}/{tname}/x/xterm-kitty'))
for w in ('simple-file', 'a/sfa', 's2'):
with open(os.path.join(remote_home, w), 'r') as f:
with open(os.path.join(remote_home, w)) as f:
self.ae(f.read(), simple_data)
self.assertFalse(os.path.islink(f.name))
self.assertTrue(os.path.lexists(f'{remote_home}/d1/y'))