summaryrefslogtreecommitdiff
path: root/genmap.py
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-09-04 18:08:40 +0300
committerMaxim Devaev <[email protected]>2022-09-04 18:08:40 +0300
commitee3e224e396494cd0d69bb6167087a071a20349c (patch)
tree5becd28570e58a03c6e1e231d0db24c264a73f88 /genmap.py
parent4b75221e9470b4a009955d7677f16adf8e23e302 (diff)
new typing style
Diffstat (limited to 'genmap.py')
-rwxr-xr-xgenmap.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/genmap.py b/genmap.py
index da512d63..5e827725 100755
--- a/genmap.py
+++ b/genmap.py
@@ -26,10 +26,6 @@ import csv
import textwrap
import dataclasses
-from typing import Set
-from typing import List
-from typing import Optional
-
import Xlib.keysymdef.latin1
import Xlib.keysymdef.miscellany
import Xlib.keysymdef.xf86
@@ -77,11 +73,11 @@ class _KeyMapping:
usb_key: _UsbKey
ps2_key: _Ps2Key
at1_code: int
- x11_keys: Set[_X11Key]
+ x11_keys: set[_X11Key]
def _resolve_keysym(name: str) -> int:
- code: Optional[int] = None
+ code: (int | None) = None
for module in [
Xlib.keysymdef.latin1,
Xlib.keysymdef.miscellany,
@@ -95,8 +91,8 @@ def _resolve_keysym(name: str) -> int:
return code
-def _parse_x11_names(names: str) -> Set[_X11Key]:
- keys: Set[_X11Key] = set()
+def _parse_x11_names(names: str) -> set[_X11Key]:
+ keys: set[_X11Key] = set()
for name in filter(None, names.split(",")):
shift = name.startswith("^")
name = (name[1:] if shift else name)
@@ -119,8 +115,8 @@ def _parse_ps2_key(key: str) -> _Ps2Key:
)
-def _read_keymap_csv(path: str) -> List[_KeyMapping]:
- keymap: List[_KeyMapping] = []
+def _read_keymap_csv(path: str) -> list[_KeyMapping]:
+ keymap: list[_KeyMapping] = []
with open(path) as keymap_file:
for row in csv.DictReader(keymap_file):
if len(row) >= 6:
@@ -135,7 +131,7 @@ def _read_keymap_csv(path: str) -> List[_KeyMapping]:
return keymap
-def _render_keymap(keymap: List[_KeyMapping], template_path: str, out_path: str) -> None:
+def _render_keymap(keymap: list[_KeyMapping], template_path: str, out_path: str) -> None:
with open(template_path) as template_file:
with open(out_path, "w") as out_file:
template = textwrap.dedent(template_file.read())