Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2022-05-30 08:46:46 +0300
committerlovetox <philipp@hoerist.com>2022-05-30 08:52:33 +0300
commitbe8659e734f58794aff81b66818822d7085807ee (patch)
tree00655729051c5ecf2f07c4641e556ed9003a595a /scripts
parent0f3a42fde2db75b666694cf258a7b6f1e032a85b (diff)
chore: Script: Add type annotations
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_ui_types.py (renamed from scripts/dev/generate_ui_types.py)11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/dev/generate_ui_types.py b/scripts/generate_ui_types.py
index 928764e07..68af45c95 100755
--- a/scripts/dev/generate_ui_types.py
+++ b/scripts/generate_ui_types.py
@@ -3,6 +3,7 @@
# Reads all .ui files and creates builder.pyi
# Excecute this script from the repo root dir
+from io import TextIOWrapper
from pathlib import Path
from xml.etree import ElementTree as ET
@@ -41,22 +42,22 @@ GET_BUILDER = '''
def get_builder(file_name: str, widgets: list[str] = ...) -> Builder: ...'''
-def make_class_name(path):
+def make_class_name(path: Path) -> str:
name = path.name.removesuffix('.ui')
names = name.split('_')
names = map(lambda x: x.capitalize(), names)
return ''.join(names) + 'Builder'
-def parse(path, file):
+def parse(path: Path, file: TextIOWrapper) -> str:
print('read', path)
- lines = []
+ lines: list[str] = []
tree = ET.parse(path)
for node in tree.iter(tag='object'):
id_ = node.attrib.get('id')
if id_ is None:
continue
- klass = node.attrib.get('class')
+ klass = node.attrib['class']
if klass.startswith('GtkSource'):
klass = f'GtkSource.{klass.removeprefix("GtkSource")}'
elif klass.startswith('Atk'):
@@ -78,7 +79,7 @@ def parse(path, file):
return klass_name
-builder_names = []
+builder_names: list[tuple[str, str]] = []
with out_path.open(mode='w', encoding='utf8') as file:
file.write(IMPORTS)