From 12f4a2c8d48d12884d980a1b429899c624feea6e Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Thu, 22 Jan 2026 17:55:29 -0500 Subject: [PATCH] lint fixes --- getmyancestors/classes/session.py | 11 +++-------- getmyancestors/classes/tree/core.py | 10 ++++++---- getmyancestors/mergemyanc.py | 6 +++++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/getmyancestors/classes/session.py b/getmyancestors/classes/session.py index 630aea2..67c5954 100644 --- a/getmyancestors/classes/session.py +++ b/getmyancestors/classes/session.py @@ -197,9 +197,8 @@ class GMASession(requests.Session): # 1. Check external license file # We store license acceptance in a separate JSON file so it survives cache clearing license_file = os.path.join( - os.path.dirname(self.db_path), "..", "license-agreement.json" + os.path.dirname(self.db_path), "license-agreement.json" ) - license_file = os.path.abspath(license_file) if os.path.exists(license_file): try: @@ -267,10 +266,7 @@ class GMASession(requests.Session): "auth": auth_header, } # Save to separate JSON file - cookie_file = os.path.join( - os.path.dirname(self.db_path), "..", "cookies.json" - ) - cookie_file = os.path.abspath(cookie_file) + cookie_file = os.path.join(os.path.dirname(self.db_path), "cookies.json") with open(cookie_file, "w", encoding="utf-8") as f: json.dump(data, f) @@ -282,8 +278,7 @@ class GMASession(requests.Session): def load_cookies(self): """load cookies and authorization header from JSON""" - cookie_file = os.path.join(os.path.dirname(self.db_path), "..", "cookies.json") - cookie_file = os.path.abspath(cookie_file) + cookie_file = os.path.join(os.path.dirname(self.db_path), "cookies.json") if os.path.exists(cookie_file): try: diff --git a/getmyancestors/classes/tree/core.py b/getmyancestors/classes/tree/core.py index 046e8a0..f1228da 100644 --- a/getmyancestors/classes/tree/core.py +++ b/getmyancestors/classes/tree/core.py @@ -983,14 +983,16 @@ class Tree: """add parents relationships :param fids: a set of fids """ + # Materialize once to avoid exhausting iterator + fids_list = [f for f in fids if f in self.indi] parents = set() - for fid in [f for f in fids if f in self.indi]: + for fid in fids_list: for couple in self.indi[fid].parents: parents |= set(couple) if parents: parents -= set(self.exclude) self.add_indis(set(filter(None, parents))) - for fid in [f for f in fids if f in self.indi]: + for fid in fids_list: for father, mother in self.indi[fid].parents: self.add_trio( self.indi.get(father) if father else None, @@ -1178,11 +1180,11 @@ class Tree: resname.text = self.display_name people = ET.SubElement(root, "people") - for indi in sorted(self.indi.values(), key=lambda x: x.id): + for indi in sorted(self.indi.values(), key=lambda x: str(x.id or "")): indi.printxml(people) families = ET.SubElement(root, "families") - for fam in sorted(self.fam.values(), key=lambda x: x.id): + for fam in sorted(self.fam.values(), key=lambda x: str(x.id or "")): fam.printxml(families) events = ET.SubElement(root, "events") diff --git a/getmyancestors/mergemyanc.py b/getmyancestors/mergemyanc.py index f1426ef..0d5b7c2 100755 --- a/getmyancestors/mergemyanc.py +++ b/getmyancestors/mergemyanc.py @@ -111,7 +111,11 @@ def main( # Deduplicate names by string representation def merge_names(target_set, source_set): - target_set.update(source_set) + existing_names = {str(n) for n in target_set} + for n in source_set: + if str(n) not in existing_names: + target_set.add(n) + existing_names.add(str(n)) # Helper for whitespace normalization in quotes def norm_space(s): -- 2.52.0