From c070ca413cbf9f30d9bae434693b8fb1addfc510 Mon Sep 17 00:00:00 2001 From: Bela Date: Wed, 21 Aug 2024 19:28:51 +0200 Subject: [PATCH] make mypy and pylint a bit happier --- location.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/location.py b/location.py index 6905a53..192bb80 100644 --- a/location.py +++ b/location.py @@ -125,7 +125,7 @@ class Schema: Then all keys are accepted. """ if self._subs is None: - return Schema(self._sub_schema_default | {"name": key}) + return type(self)(self._sub_schema_default | {"name": key}) suitably_named_subs = [sub for sub in self._subs if sub.name == key] if len(suitably_named_subs) == 1: return suitably_named_subs[0] @@ -207,7 +207,8 @@ class Schema: return [f"{sub.name} ({sub.shortcut})" for sub in self._subs] if shortcuts == '*': return [(f"{str(sub.name)[:str(sub.name).index(str(sub.shortcut))]}**{sub.shortcut}**" - f"{str(sub.name)[str(sub.name).index(str(sub.shortcut)) + len(str(sub.shortcut)):]}") + + str(sub.name)[str(sub.name).index(str(sub.shortcut)) + + len(str(sub.shortcut)):]) if str(sub.shortcut) in str(sub.name) else f"{sub.name} ({sub.shortcut})" for sub in self._subs] @@ -282,8 +283,9 @@ class Location: that created the location -- shortcuts by names and adds default locations. """ - as_json = {level.levelname: self._levels[index + 1].name - for index, level in list(enumerate(self._levels))[:-1]} + as_json: dict[str, Union[str, int, float, bool]] = { + level.levelname: self._levels[index + 1].name + for index, level in list(enumerate(self._levels))[:-1]} as_json.update({key: value for key, value in self._level_infos.items() if not ("sign" in key or key in as_json)}) @@ -361,7 +363,7 @@ if __name__ == "__main__": "I hope you have saved the status before starting this script in your git.") with open("locations.json", encoding="UTF-8") as location_file: gl_json_content = json.load(location_file) - _, _, gl_location_dict = load_location_json(gl_json_content) + _, __, gl_location_dict = load_location_json(gl_json_content) print({name: str(location) for name, location in gl_location_dict.items()}) gl_new_json_content = get_location_json(