From 519d3d36c38fb68945c2d42ba3bc5786c27aa693 Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Fri, 25 Oct 2024 14:38:31 +0200 Subject: [PATCH] Add type annotations to Spacer Task-number: QTBUG-129564 Pick-to: 6.8 Change-Id: I942d135da630f7ba6641170a1a597b0578aca878 Reviewed-by: Cristian Maureira-Fredes --- util/locale_database/qlocalexml.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/util/locale_database/qlocalexml.py b/util/locale_database/qlocalexml.py index 8b2bb84cc41..4545369801a 100644 --- a/util/locale_database/qlocalexml.py +++ b/util/locale_database/qlocalexml.py @@ -571,7 +571,7 @@ def __eachEltInGroup(cls, parent: minidom.Element, group: str, key: str class Spacer (object): - def __init__(self, indent = None, initial = ''): + def __init__(self, indent:str|int|None = None, initial: str = '') -> None: """Prepare to manage indentation and line breaks. Arguments are both optional. @@ -590,17 +590,17 @@ def __init__(self, indent = None, initial = ''): an end-tag. The text is not parsed any more carefully than just described.""" if indent is None: - self.__call = lambda x: x + self.__call: Callable[[str], str] = lambda x: x else: - self.__each = ' ' * indent if isinstance(indent, int) else indent + self.__each: str = ' ' * indent if isinstance(indent, int) else indent self.current = initial self.__call = self.__wrap - def __wrap(self, line): + def __wrap(self, line: str) -> str: if not line: return '\n' - indent = self.current + indent: str = self.current if line.startswith(' str: return self.__call(line) class QLocaleXmlWriter (object):