Run pyupgrade to update the codebase to python 3.9

Gets rid of a lot of typing ugliness by using type annotations on
builtin types
This commit is contained in:
Kovid Goyal
2024-07-31 07:55:27 +05:30
parent 3aac62f6c7
commit f1d0d0949b
48 changed files with 593 additions and 602 deletions

View File

@@ -1,9 +1,10 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
from collections.abc import Iterator, Mapping, Sequence
from enum import Enum
from functools import update_wrapper
from typing import TYPE_CHECKING, Any, Callable, Dict, Generic, Iterator, Mapping, NamedTuple, Optional, Sequence, Tuple, TypedDict, TypeVar, Union
from typing import TYPE_CHECKING, Any, Callable, Generic, NamedTuple, Optional, TypedDict, TypeVar, Union
if TYPE_CHECKING:
from kitty.fast_data_types import SingleKey
@@ -95,7 +96,7 @@ def human_repr_of_single_key(self: 'SingleKey', kitty_mod: int) -> str:
class Shortcut(NamedTuple):
keys: Tuple['SingleKey', ...]
keys: tuple['SingleKey', ...]
def human_repr(self, kitty_mod: int = 0) -> str:
return ' > '.join(human_repr_of_single_key(k, kitty_mod) for k in self.keys)
@@ -182,7 +183,7 @@ def run_once(f: Callable[[], _T]) -> 'RunOnce[_T]':
@run_once
def modmap() -> Dict[str, int]:
def modmap() -> dict[str, int]:
from .constants import is_macos
from .fast_data_types import (
GLFW_MOD_ALT,