From 258562f8aa0f432f77959ae24eaff4b51dda05d6 Mon Sep 17 00:00:00 2001 From: bashrc Date: Tue, 5 May 2026 13:36:14 +0100 Subject: [PATCH] Check property types --- briar.py | 18 +++++++----- cwtch.py | 22 +++++++++----- discord.py | 26 ++++++++++------- donate.py | 31 ++++++++++++-------- enigma.py | 22 +++++++++----- git.py | 10 ++++--- lxmf.py | 26 ++++++++++------- matrix.py | 28 +++++++++++------- peertube.py | 24 +++++++++------ pgp.py | 84 +++++++++++++++++++++++++++++++++-------------------- pixelfed.py | 24 +++++++++------ pronouns.py | 24 +++++++++------ ssb.py | 8 +++-- 13 files changed, 216 insertions(+), 131 deletions(-) diff --git a/briar.py b/briar.py index b99f86dcb..b58bc91b1 100644 --- a/briar.py +++ b/briar.py @@ -23,11 +23,13 @@ def get_briar_address(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not name_value.lower().startswith('briar'): @@ -86,12 +88,12 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None: actor_json['attachment']: list[dict] = [] # remove any existing value - property_found = None + property_found: dict = None for property_value in actor_json['attachment']: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): name_value = property_value['name'] elif property_value.get('schema:name'): @@ -115,9 +117,11 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/cwtch.py b/cwtch.py index 6994d5470..c07494625 100644 --- a/cwtch.py +++ b/cwtch.py @@ -23,11 +23,13 @@ def get_cwtch_address(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not name_value.lower().startswith('cwtch'): @@ -77,11 +79,13 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -101,9 +105,11 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/discord.py b/discord.py index 9f17b25bb..f368d9580 100644 --- a/discord.py +++ b/discord.py @@ -26,11 +26,13 @@ def get_discord(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not string_contains(name_value, discord_fieldnames): @@ -43,7 +45,7 @@ def get_discord(actor_json: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - discord_text = property_value[prop_value_name] + discord_text: str = property_value[prop_value_name] return remove_html(discord_text) return '' @@ -55,16 +57,18 @@ def set_discord(actor_json: {}, discord: str) -> None: actor_json['attachment']: list[dict] = [] # remove any existing value - property_found = None + property_found: dict = None for property_value in actor_json['attachment']: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue name_value = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not property_value.get('type'): @@ -81,11 +85,13 @@ def set_discord(actor_json: {}, discord: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/donate.py b/donate.py index fee825fc7..680873611 100644 --- a/donate.py +++ b/donate.py @@ -36,14 +36,16 @@ def get_donation_url(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue - name_value_lower = name_value.lower() + name_value_lower: str = name_value.lower() found: bool = False for donation_type_str in donation_type_list: if donation_type_str in name_value_lower: @@ -64,13 +66,14 @@ def get_donation_url(actor_json: {}) -> str: if not property_value['type'].endswith('PropertyValue'): continue if ' None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -135,11 +140,13 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/enigma.py b/enigma.py index c9d6da13c..9fd94ba71 100644 --- a/enigma.py +++ b/enigma.py @@ -23,11 +23,13 @@ def get_enigma_pub_key(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not name_value.lower().startswith('enigma'): @@ -60,11 +62,13 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -84,9 +88,11 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/git.py b/git.py index 27837e663..2530853de 100644 --- a/git.py +++ b/git.py @@ -240,11 +240,13 @@ def get_repo_url(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if name_value.lower() not in repo_type: @@ -268,7 +270,7 @@ def get_repo_url(actor_json: {}) -> str: repo_url = remove_html(repo_url) return remove_link_tracking(repo_url) - repo_sites = ('github.com', 'gitlab.com', 'codeberg.org') + repo_sites: list[str] = ('github.com', 'gitlab.com', 'codeberg.org') for property_value in actor_json['attachment']: if not isinstance(property_value, dict): diff --git a/lxmf.py b/lxmf.py index 799e2126a..799cef485 100644 --- a/lxmf.py +++ b/lxmf.py @@ -70,11 +70,13 @@ def get_lxmf_address(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue name_value_lower = name_value.lower() @@ -89,7 +91,7 @@ def get_lxmf_address(actor_json: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - lxmf_address = property_value[prop_value_name].strip() + lxmf_address: str = property_value[prop_value_name].strip() # remove any prefix if lxmf_address.startswith('lxmf://'): @@ -134,11 +136,13 @@ def set_lxmf_address(base_dir: str, nickname: str, domain: str, if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -156,11 +160,13 @@ def set_lxmf_address(base_dir: str, nickname: str, domain: str, if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/matrix.py b/matrix.py index a96cea38e..fff61d0dd 100644 --- a/matrix.py +++ b/matrix.py @@ -23,14 +23,16 @@ def get_matrix_address(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue - name_value_lower = name_value.lower() + name_value_lower: str = name_value.lower() if not name_value_lower.startswith('matrix'): if not name_value_lower.startswith('chat'): continue @@ -45,7 +47,7 @@ def get_matrix_address(actor_json: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - address_text = remove_html(property_value[prop_value_name]) + address_text: str = remove_html(property_value[prop_value_name]) if 'xmpp' in address_text.lower(): continue if 'jabber' in address_text.lower(): @@ -82,11 +84,13 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -115,11 +119,13 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/peertube.py b/peertube.py index 0eff34f84..69798b08b 100644 --- a/peertube.py +++ b/peertube.py @@ -26,11 +26,13 @@ def get_peertube(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not string_contains(name_value, peertube_fieldnames): @@ -58,7 +60,7 @@ def get_peertube(actor_json: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - peertube_text = property_value[prop_value_name] + peertube_text: str = property_value[prop_value_name] if '//peertube.' not in peertube_text: continue return remove_html(peertube_text) @@ -79,9 +81,11 @@ def set_peertube(actor_json: {}, peertube: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not property_value.get('type'): @@ -98,11 +102,13 @@ def set_peertube(actor_json: {}, peertube: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/pgp.py b/pgp.py index 582a7343a..6de3a8664 100644 --- a/pgp.py +++ b/pgp.py @@ -55,14 +55,16 @@ def get_email_address(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue - name_value_lower = name_value.lower() + name_value_lower: str = name_value.lower() if 'email' not in name_value_lower: if 'e-mail' not in name_value_lower: if 'electronic mail' not in name_value_lower: @@ -75,7 +77,7 @@ def get_email_address(actor_json: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - value_str = remove_html(property_value[prop_value_name]) + value_str: str = remove_html(property_value[prop_value_name]) if '://' in value_str: continue if '@' not in value_str: @@ -101,11 +103,13 @@ def get_deltachat_invite(actor_json: {}, translate: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue found: bool = False @@ -123,7 +127,7 @@ def get_deltachat_invite(actor_json: {}, translate: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - value_str = remove_html(property_value[prop_value_name]) + value_str: str = remove_html(property_value[prop_value_name]) if 'https://' not in value_str and \ 'http://' not in value_str: continue @@ -140,11 +144,13 @@ def get_pgp_pub_key(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not name_value.lower().startswith('pgp'): @@ -174,9 +180,11 @@ def get_pgp_fingerprint(actor_json: {}) -> str: continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not name_value.lower().startswith('openpgp'): @@ -212,16 +220,18 @@ def set_email_address(actor_json: {}, email_address: str) -> None: actor_json['attachment']: list[dict] = [] # remove any existing value - property_found = None + property_found: dict = None for property_value in actor_json['attachment']: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -239,11 +249,13 @@ def set_email_address(actor_json: {}, email_address: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -296,6 +308,8 @@ def set_deltachat_invite(actor_json: {}, invite_link: str, continue if not property_value.get('name'): continue + if not isinstance(property_value['name'], str): + continue if not property_value.get('type'): continue if property_value['name'].lower() not in match_strings: @@ -336,11 +350,13 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -360,9 +376,11 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -405,11 +423,13 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): @@ -427,11 +447,13 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/pixelfed.py b/pixelfed.py index 5ae9c50c6..02fc48923 100644 --- a/pixelfed.py +++ b/pixelfed.py @@ -30,11 +30,13 @@ def get_pixelfed(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not string_contains(name_value, pixelfed_fieldnames): @@ -47,12 +49,12 @@ def get_pixelfed(actor_json: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - pixelfed_text = remove_html(property_value[prop_value_name]) + pixelfed_text: str = remove_html(property_value[prop_value_name]) if not resembles_url(pixelfed_text): if '@' not in pixelfed_text: continue # a pixelfed handle has been given, rather than a url - nickname = get_nickname_from_actor(pixelfed_text) + nickname: str = get_nickname_from_actor(pixelfed_text) domain, port = get_domain_from_actor(pixelfed_text) if not nickname or not domain: continue @@ -102,9 +104,11 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not property_value.get('type'): @@ -123,9 +127,11 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/pronouns.py b/pronouns.py index bf75a6c77..760dc81ae 100644 --- a/pronouns.py +++ b/pronouns.py @@ -26,11 +26,13 @@ def get_pronouns(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not string_contains(name_value, pronoun_fieldnames): @@ -43,7 +45,7 @@ def get_pronouns(actor_json: {}) -> str: continue if not property_value['type'].endswith('PropertyValue'): continue - pronouns_text = property_value[prop_value_name] + pronouns_text: str = property_value[prop_value_name] return remove_html(pronouns_text) return '' @@ -60,11 +62,13 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'].lower() + if isinstance(property_value['name'], str): + name_value = property_value['name'].lower() elif property_value.get('schema:name'): - name_value = property_value['schema:name'].lower() + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'].lower() if not name_value: continue if not property_value.get('type'): @@ -83,9 +87,11 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None: continue name_value = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not property_value.get('type'): diff --git a/ssb.py b/ssb.py index 5f2bdc054..f20aa285c 100644 --- a/ssb.py +++ b/ssb.py @@ -23,11 +23,13 @@ def get_ssb_address(actor_json: {}) -> str: if not isinstance(property_value, dict): print("WARN: actor attachment is not dict: " + str(property_value)) continue - name_value = None + name_value: str = None if property_value.get('name'): - name_value = property_value['name'] + if isinstance(property_value['name'], str): + name_value = property_value['name'] elif property_value.get('schema:name'): - name_value = property_value['schema:name'] + if isinstance(property_value['schema:name'], str): + name_value = property_value['schema:name'] if not name_value: continue if not name_value.lower().startswith('ssb'):