Add list types

merge-requests/30/head
Bob Mottram 2024-12-23 18:23:47 +00:00
parent a859ff14ac
commit 8e67d4910f
27 changed files with 196 additions and 196 deletions

182
tests.py
View File

@ -1089,7 +1089,7 @@ def create_server_bob(path: str, domain: str, port: int,
lists_enabled = '' lists_enabled = ''
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
dyslexic_font = False dyslexic_font = False
crawlers_allowed = [] crawlers_allowed: list[str] = []
check_actor_timeout = 2 check_actor_timeout = 2
preferred_podcast_formats = None preferred_podcast_formats = None
clacks = None clacks = None
@ -1146,7 +1146,7 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
shutil.rmtree(path, ignore_errors=False) shutil.rmtree(path, ignore_errors=False)
os.mkdir(path) os.mkdir(path)
os.chdir(path) os.chdir(path)
shared_items_federated_domains = [] shared_items_federated_domains: list[str] = []
nickname = 'eve' nickname = 'eve'
http_prefix = 'http' http_prefix = 'http'
proxy_type = None proxy_type = None
@ -1179,14 +1179,14 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
show_node_info_version = True show_node_info_version = True
city = 'London, England' city = 'London, England'
log_login_failures = False log_login_failures = False
user_agents_blocked = [] user_agents_blocked: list[str] = []
max_like_count = 10 max_like_count = 10
low_bandwidth = True low_bandwidth = True
default_reply_interval_hrs = 9999999999 default_reply_interval_hrs = 9999999999
lists_enabled = '' lists_enabled = ''
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
dyslexic_font = False dyslexic_font = False
crawlers_allowed = [] crawlers_allowed: list[str] = []
check_actor_timeout = 2 check_actor_timeout = 2
preferred_podcast_formats = None preferred_podcast_formats = None
clacks = None clacks = None
@ -1268,7 +1268,7 @@ def create_server_group(path: str, domain: str, port: int,
shutil.rmtree(path, ignore_errors=False) shutil.rmtree(path, ignore_errors=False)
os.mkdir(path) os.mkdir(path)
os.chdir(path) os.chdir(path)
shared_items_federated_domains = [] shared_items_federated_domains: list[str] = []
# system_language = 'en' # system_language = 'en'
nickname = 'testgroup' nickname = 'testgroup'
http_prefix = 'http' http_prefix = 'http'
@ -1304,14 +1304,14 @@ def create_server_group(path: str, domain: str, port: int,
show_node_info_version = True show_node_info_version = True
city = 'London, England' city = 'London, England'
log_login_failures = False log_login_failures = False
user_agents_blocked = [] user_agents_blocked: list[str] = []
max_like_count = 10 max_like_count = 10
low_bandwidth = True low_bandwidth = True
default_reply_interval_hrs = 9999999999 default_reply_interval_hrs = 9999999999
lists_enabled = '' lists_enabled = ''
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
dyslexic_font = False dyslexic_font = False
crawlers_allowed = [] crawlers_allowed: list[str] = []
check_actor_timeout = 2 check_actor_timeout = 2
preferred_podcast_formats = None preferred_podcast_formats = None
clacks = None clacks = None
@ -1446,7 +1446,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
cc_url = None cc_url = None
alice_person_cache = {} alice_person_cache = {}
alice_cached_webfingers = {} alice_cached_webfingers = {}
alice_shared_items_federated_domains = [] alice_shared_items_federated_domains: list[str] = []
alice_shared_item_federation_tokens = {} alice_shared_item_federation_tokens = {}
attached_image_filename = base_dir + '/img/logo.png' attached_image_filename = base_dir + '/img/logo.png'
test_image_width, test_image_height = \ test_image_width, test_image_height = \
@ -1471,8 +1471,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
buy_url = '' buy_url = ''
chat_url = '' chat_url = ''
auto_cw_cache = {} auto_cw_cache = {}
searchable_by = [] searchable_by: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -1592,7 +1592,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
bob_post_log = [] bob_post_log = []
bob_person_cache = {} bob_person_cache = {}
bob_cached_webfingers = {} bob_cached_webfingers = {}
sites_unavailable = [] sites_unavailable: list[str] = []
status_number = None status_number = None
outbox_post_filename = None outbox_post_filename = None
outbox_path = data_dir(alice_dir) + '/alice@' + alice_domain + '/outbox' outbox_path = data_dir(alice_dir) + '/alice@' + alice_domain + '/outbox'
@ -1603,7 +1603,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
outbox_post_filename = outbox_path + '/' + name outbox_post_filename = outbox_path + '/' + name
assert status_number > 0 assert status_number > 0
assert outbox_post_filename assert outbox_post_filename
mitm_servers = [] mitm_servers: list[str] = []
assert like_post({}, session_bob, bob_dir, federation_list, assert like_post({}, session_bob, bob_dir, federation_list,
'bob', bob_domain, bob_port, http_prefix, 'bob', bob_domain, bob_port, http_prefix,
'alice', alice_domain, alice_port, [], 'alice', alice_domain, alice_port, [],
@ -1627,8 +1627,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
print('\n\n*******************************************************') print('\n\n*******************************************************')
print("Bob reacts to Alice's post") print("Bob reacts to Alice's post")
sites_unavailable = [] sites_unavailable: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
assert reaction_post({}, session_bob, bob_dir, federation_list, assert reaction_post({}, session_bob, bob_dir, federation_list,
'bob', bob_domain, bob_port, http_prefix, 'bob', bob_domain, bob_port, http_prefix,
'alice', alice_domain, alice_port, [], 'alice', alice_domain, alice_port, [],
@ -1669,8 +1669,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
print('outbox items before announce: ' + str(outbox_before_announce_count)) print('outbox items before announce: ' + str(outbox_before_announce_count))
assert outbox_before_announce_count == 0 assert outbox_before_announce_count == 0
assert before_announce_count == 0 assert before_announce_count == 0
sites_unavailable = [] sites_unavailable: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
announce_public(session_bob, bob_dir, federation_list, announce_public(session_bob, bob_dir, federation_list,
'bob', bob_domain, bob_port, http_prefix, 'bob', bob_domain, bob_port, http_prefix,
object_url, object_url,
@ -1731,7 +1731,7 @@ def test_follow_between_servers(base_dir: str) -> None:
languages_understood = [system_language] languages_understood = [system_language]
http_prefix = 'http' http_prefix = 'http'
proxy_type = None proxy_type = None
federation_list = [] federation_list: list[str] = []
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_creator = 'Penfold' media_creator = 'Penfold'
@ -1814,10 +1814,10 @@ def test_follow_between_servers(base_dir: str) -> None:
alice_person_cache = {} alice_person_cache = {}
alice_cached_webfingers = {} alice_cached_webfingers = {}
alice_post_log = [] alice_post_log = []
sites_unavailable = [] sites_unavailable: list[str] = []
bob_actor = http_prefix + '://' + bob_address + '/users/bob' bob_actor = http_prefix + '://' + bob_address + '/users/bob'
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_follow_request(session_alice, alice_dir, send_follow_request(session_alice, alice_dir,
'alice', alice_domain, 'alice', alice_domain,
@ -1863,7 +1863,7 @@ def test_follow_between_servers(base_dir: str) -> None:
alice_post_log = [] alice_post_log = []
alice_person_cache = {} alice_person_cache = {}
alice_cached_webfingers = {} alice_cached_webfingers = {}
alice_shared_items_federated_domains = [] alice_shared_items_federated_domains: list[str] = []
alice_shared_item_federation_tokens = {} alice_shared_item_federation_tokens = {}
alice_post_log = [] alice_post_log = []
is_article = False is_article = False
@ -1875,8 +1875,8 @@ def test_follow_between_servers(base_dir: str) -> None:
chat_url = '' chat_url = ''
video_transcript = None video_transcript = None
auto_cw_cache = {} auto_cw_cache = {}
searchable_by = [] searchable_by: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -1940,7 +1940,7 @@ def test_shared_items_federation(base_dir: str) -> None:
languages_understood = [system_language] languages_understood = [system_language]
http_prefix = 'http' http_prefix = 'http'
proxy_type = None proxy_type = None
federation_list = [] federation_list: list[str] = []
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_creator = 'Dr Drokk' media_creator = 'Dr Drokk'
@ -2021,7 +2021,7 @@ def test_shared_items_federation(base_dir: str) -> None:
'host': bob_address, 'host': bob_address,
'Accept': 'application/ld+json; profile="' + profile_str + '"' 'Accept': 'application/ld+json; profile="' + profile_str + '"'
} }
mitm_servers = [] mitm_servers: list[str] = []
bob_instance_actor_json = \ bob_instance_actor_json = \
get_json(signing_priv_key_pem, session_client, get_json(signing_priv_key_pem, session_client,
'http://' + bob_address + '/@actor', test_headers, {}, True, 'http://' + bob_address + '/@actor', test_headers, {}, True,
@ -2056,8 +2056,8 @@ def test_shared_items_federation(base_dir: str) -> None:
alice_person_cache = {} alice_person_cache = {}
alice_cached_webfingers = {} alice_cached_webfingers = {}
alice_post_log = [] alice_post_log = []
sites_unavailable = [] sites_unavailable: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
bob_actor = http_prefix + '://' + bob_address + '/users/bob' bob_actor = http_prefix + '://' + bob_address + '/users/bob'
send_result = \ send_result = \
send_follow_request(session_alice, alice_dir, send_follow_request(session_alice, alice_dir,
@ -2133,7 +2133,7 @@ def test_shared_items_federation(base_dir: str) -> None:
shared_item_price = "1.30" shared_item_price = "1.30"
shared_item_currency = "EUR" shared_item_currency = "EUR"
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
session_bob = create_session(proxy_type) session_bob = create_session(proxy_type)
share_json = \ share_json = \
send_share_via_server(bob_dir, session_bob, send_share_via_server(bob_dir, session_bob,
@ -2226,7 +2226,7 @@ def test_shared_items_federation(base_dir: str) -> None:
print('\n\n*********************************************************') print('\n\n*********************************************************')
print('Bob can read the shared items catalog on his own instance') print('Bob can read the shared items catalog on his own instance')
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
catalog_json = \ catalog_json = \
get_shared_items_catalog_via_server(session_bob, get_shared_items_catalog_via_server(session_bob,
'bob', bob_password, 'bob', bob_password,
@ -2239,7 +2239,7 @@ def test_shared_items_federation(base_dir: str) -> None:
assert 'DFC:supplies' in catalog_json assert 'DFC:supplies' in catalog_json
assert len(catalog_json.get('DFC:supplies')) == 3 assert len(catalog_json.get('DFC:supplies')) == 3
mitm_servers = [] mitm_servers: list[str] = []
offers_json = \ offers_json = \
get_offers_via_server(session_bob, 'bob', bob_password, get_offers_via_server(session_bob, 'bob', bob_password,
bob_domain, bob_port, bob_domain, bob_port,
@ -2252,7 +2252,7 @@ def test_shared_items_federation(base_dir: str) -> None:
assert isinstance(offers_json, dict) assert isinstance(offers_json, dict)
assert len(offers_json['orderedItems']) >= 1 assert len(offers_json['orderedItems']) >= 1
mitm_servers = [] mitm_servers: list[str] = []
wanted_json = \ wanted_json = \
get_wanted_via_server(session_bob, 'bob', bob_password, get_wanted_via_server(session_bob, 'bob', bob_password,
bob_domain, bob_port, bob_domain, bob_port,
@ -2290,8 +2290,8 @@ def test_shared_items_federation(base_dir: str) -> None:
chat_url = '' chat_url = ''
video_transcript = None video_transcript = None
auto_cw_cache = {} auto_cw_cache = {}
searchable_by = [] searchable_by: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -2412,7 +2412,7 @@ def test_group_follow(base_dir: str) -> None:
# system_language = 'en' # system_language = 'en'
http_prefix = 'http' http_prefix = 'http'
proxy_type = None proxy_type = None
federation_list = [] federation_list: list[str] = []
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_creator = 'Bumble' media_creator = 'Bumble'
@ -2514,7 +2514,7 @@ def test_group_follow(base_dir: str) -> None:
'Accept': 'application/ld+json; profile="' + profile_str + '"' 'Accept': 'application/ld+json; profile="' + profile_str + '"'
} }
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
outbox_json = get_json(signing_priv_key_pem, session, alice_outbox, outbox_json = get_json(signing_priv_key_pem, session, alice_outbox,
as_header, None, True, mitm_servers, as_header, None, True, mitm_servers,
__version__, 'http', None) __version__, 'http', None)
@ -2527,7 +2527,7 @@ def test_group_follow(base_dir: str) -> None:
print('Alice outbox totalItems: ' + str(outbox_json['totalItems'])) print('Alice outbox totalItems: ' + str(outbox_json['totalItems']))
assert outbox_json['totalItems'] == 3 assert outbox_json['totalItems'] == 3
mitm_servers = [] mitm_servers: list[str] = []
outbox_json = get_json(signing_priv_key_pem, session, outbox_json = get_json(signing_priv_key_pem, session,
first_page, as_header, first_page, as_header,
None, True, mitm_servers, __version__, 'http', None) None, True, mitm_servers, __version__, 'http', None)
@ -2558,12 +2558,12 @@ def test_group_follow(base_dir: str) -> None:
alice_person_cache = {} alice_person_cache = {}
alice_cached_webfingers = {} alice_cached_webfingers = {}
alice_post_log = [] alice_post_log = []
sites_unavailable = [] sites_unavailable: list[str] = []
# aliceActor = http_prefix + '://' + alice_address + '/users/alice' # aliceActor = http_prefix + '://' + alice_address + '/users/alice'
testgroup_actor = \ testgroup_actor = \
http_prefix + '://' + testgroupAddress + '/users/testgroup' http_prefix + '://' + testgroupAddress + '/users/testgroup'
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_follow_request(session_alice, alice_dir, send_follow_request(session_alice, alice_dir,
'alice', alice_domain, 'alice', alice_domain,
@ -2639,12 +2639,12 @@ def test_group_follow(base_dir: str) -> None:
bob_person_cache = {} bob_person_cache = {}
bob_cached_webfingers = {} bob_cached_webfingers = {}
bob_post_log = [] bob_post_log = []
sites_unavailable = [] sites_unavailable: list[str] = []
# bob_actor = http_prefix + '://' + bob_address + '/users/bob' # bob_actor = http_prefix + '://' + bob_address + '/users/bob'
testgroup_actor = \ testgroup_actor = \
http_prefix + '://' + testgroupAddress + '/users/testgroup' http_prefix + '://' + testgroupAddress + '/users/testgroup'
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_follow_request(session_bob, bob_dir, send_follow_request(session_bob, bob_dir,
'bob', bob_domain, 'bob', bob_domain,
@ -2713,7 +2713,7 @@ def test_group_follow(base_dir: str) -> None:
alice_post_log = [] alice_post_log = []
alice_person_cache = {} alice_person_cache = {}
alice_cached_webfingers = {} alice_cached_webfingers = {}
alice_shared_items_federated_domains = [] alice_shared_items_federated_domains: list[str] = []
alice_shared_item_federation_tokens = {} alice_shared_item_federation_tokens = {}
alice_post_log = [] alice_post_log = []
is_article = False is_article = False
@ -2740,8 +2740,8 @@ def test_group_follow(base_dir: str) -> None:
chat_url = '' chat_url = ''
video_transcript = None video_transcript = None
auto_cw_cache = {} auto_cw_cache = {}
searchable_by = [] searchable_by: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_post(signing_priv_key_pem, __version__, send_post(signing_priv_key_pem, __version__,
session_alice, alice_dir, 'alice', alice_domain, alice_port, session_alice, alice_dir, 'alice', alice_domain, alice_port,
@ -2844,7 +2844,7 @@ def _test_followers_of_person(base_dir: str) -> None:
password = 'birb' password = 'birb'
port = 80 port = 80
http_prefix = 'https' http_prefix = 'https'
federation_list = [] federation_list: list[str] = []
base_dir = curr_dir + '/.tests_followersofperson' base_dir = curr_dir + '/.tests_followersofperson'
if os.path.isdir(base_dir): if os.path.isdir(base_dir):
shutil.rmtree(base_dir, ignore_errors=False) shutil.rmtree(base_dir, ignore_errors=False)
@ -2894,7 +2894,7 @@ def _test_followers_on_domain(base_dir: str) -> None:
password = 'birb' password = 'birb'
port = 80 port = 80
http_prefix = 'https' http_prefix = 'https'
federation_list = [] federation_list: list[str] = []
base_dir = curr_dir + '/.tests_nooffollowersOndomain' base_dir = curr_dir + '/.tests_nooffollowersOndomain'
if os.path.isdir(base_dir): if os.path.isdir(base_dir):
shutil.rmtree(base_dir, ignore_errors=False) shutil.rmtree(base_dir, ignore_errors=False)
@ -2961,7 +2961,7 @@ def _test_group_followers(base_dir: str) -> None:
password = 'somepass' password = 'somepass'
port = 80 port = 80
http_prefix = 'https' http_prefix = 'https'
federation_list = [] federation_list: list[str] = []
base_dir = curr_dir + '/.tests_testgroupfollowers' base_dir = curr_dir + '/.tests_testgroupfollowers'
if os.path.isdir(base_dir): if os.path.isdir(base_dir):
shutil.rmtree(base_dir, ignore_errors=False) shutil.rmtree(base_dir, ignore_errors=False)
@ -3141,7 +3141,7 @@ def _test_create_person_account(base_dir: str):
buy_url = '' buy_url = ''
chat_url = '' chat_url = ''
auto_cw_cache = {} auto_cw_cache = {}
searchable_by = [] searchable_by: list[str] = []
session = None session = None
test_post_json = \ test_post_json = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -3276,7 +3276,7 @@ def test_client_to_server(base_dir: str):
languages_understood = [system_language] languages_understood = [system_language]
http_prefix = 'http' http_prefix = 'http'
proxy_type = None proxy_type = None
federation_list = [] federation_list: list[str] = []
low_bandwidth = False low_bandwidth = False
if os.path.isdir(base_dir + '/.tests'): if os.path.isdir(base_dir + '/.tests'):
@ -3396,8 +3396,8 @@ def test_client_to_server(base_dir: str):
chat_url = '' chat_url = ''
video_transcript = None video_transcript = None
auto_cw_cache = {} auto_cw_cache = {}
searchable_by = [] searchable_by: list[str] = []
mitm_servers = [] mitm_servers: list[str] = []
send_result = \ send_result = \
send_post_via_server(signing_priv_key_pem, __version__, send_post_via_server(signing_priv_key_pem, __version__,
alice_dir, session_alice, 'alice', password, alice_dir, session_alice, 'alice', password,
@ -3483,7 +3483,7 @@ def test_client_to_server(base_dir: str):
print('\n\nAlice follows Bob') print('\n\nAlice follows Bob')
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
send_follow_request_via_server(alice_dir, session_alice, send_follow_request_via_server(alice_dir, session_alice,
'alice', password, 'alice', password,
alice_domain, alice_port, alice_domain, alice_port,
@ -3526,7 +3526,7 @@ def test_client_to_server(base_dir: str):
alice_domain, alice_port) alice_domain, alice_port)
print('\n\nEVENT: Bob follows Alice') print('\n\nEVENT: Bob follows Alice')
mitm_servers = [] mitm_servers: list[str] = []
send_follow_request_via_server(alice_dir, session_alice, send_follow_request_via_server(alice_dir, session_alice,
'bob', 'bobpass', 'bob', 'bobpass',
bob_domain, bob_port, bob_domain, bob_port,
@ -3620,7 +3620,7 @@ def test_client_to_server(base_dir: str):
assert 'VEVENT' not in str(result) assert 'VEVENT' not in str(result)
print('\n\nEVENT: Bob likes the post') print('\n\nEVENT: Bob likes the post')
mitm_servers = [] mitm_servers: list[str] = []
send_like_via_server(bob_dir, session_bob, send_like_via_server(bob_dir, session_bob,
'bob', 'bobpass', 'bob', 'bobpass',
bob_domain, bob_port, bob_domain, bob_port,
@ -3652,7 +3652,7 @@ def test_client_to_server(base_dir: str):
print('EVENT: Post liked') print('EVENT: Post liked')
print('\n\nEVENT: Bob reacts to the post') print('\n\nEVENT: Bob reacts to the post')
mitm_servers = [] mitm_servers: list[str] = []
send_reaction_via_server(bob_dir, session_bob, send_reaction_via_server(bob_dir, session_bob,
'bob', 'bobpass', 'bob', 'bobpass',
bob_domain, bob_port, bob_domain, bob_port,
@ -3701,7 +3701,7 @@ def test_client_to_server(base_dir: str):
show_test_boxes('bob', bob_inbox_path, bob_outbox_path) show_test_boxes('bob', bob_inbox_path, bob_outbox_path)
print('\n\nEVENT: Bob repeats the post') print('\n\nEVENT: Bob repeats the post')
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
send_announce_via_server(bob_dir, session_bob, 'bob', password, send_announce_via_server(bob_dir, session_bob, 'bob', password,
bob_domain, bob_port, bob_domain, bob_port,
http_prefix, outbox_post_id, http_prefix, outbox_post_id,
@ -3744,7 +3744,7 @@ def test_client_to_server(base_dir: str):
print('\n\nEVENT: Alice deletes her post: ' + outbox_post_id + ' ' + print('\n\nEVENT: Alice deletes her post: ' + outbox_post_id + ' ' +
str(alice_posts_before)) str(alice_posts_before))
password = 'alicepass' password = 'alicepass'
mitm_servers = [] mitm_servers: list[str] = []
send_delete_via_server(alice_dir, session_alice, 'alice', password, send_delete_via_server(alice_dir, session_alice, 'alice', password,
alice_domain, alice_port, alice_domain, alice_port,
http_prefix, outbox_post_id, http_prefix, outbox_post_id,
@ -3775,7 +3775,7 @@ def test_client_to_server(base_dir: str):
print('\n\nEVENT: Alice unfollows Bob') print('\n\nEVENT: Alice unfollows Bob')
password = 'alicepass' password = 'alicepass'
mitm_servers = [] mitm_servers: list[str] = []
send_unfollow_request_via_server(base_dir, session_alice, send_unfollow_request_via_server(base_dir, session_alice,
'alice', password, 'alice', password,
alice_domain, alice_port, alice_domain, alice_port,
@ -4048,7 +4048,7 @@ def _test_addemoji(base_dir: str):
nickname = 'testuser' nickname = 'testuser'
domain = 'testdomain.net' domain = 'testdomain.net'
port = 3682 port = 3682
recipients = [] recipients: list[str] = []
translate = {} translate = {}
hashtags = {} hashtags = {}
base_dir_original = base_dir base_dir_original = base_dir
@ -4080,7 +4080,7 @@ def _test_addemoji(base_dir: str):
assert ':lemon:' in content_modified assert ':lemon:' in content_modified
assert content_modified.startswith('<p>') assert content_modified.startswith('<p>')
assert content_modified.endswith('</p>') assert content_modified.endswith('</p>')
tags = [] tags: list[dict] = []
for _, tag in hashtags.items(): for _, tag in hashtags.items():
tags.append(tag) tags.append(tag)
content = content_modified content = content_modified
@ -4307,7 +4307,7 @@ def _test_jsonld():
def _test_site_active(): def _test_site_active():
print('test_site_is_active') print('test_site_is_active')
timeout = 10 timeout = 10
sites_unavailable = [] sites_unavailable: list[str] = []
# at least one site should resolve # at least one site should resolve
if not site_is_active('https://archive.org', timeout, sites_unavailable): if not site_is_active('https://archive.org', timeout, sites_unavailable):
if not site_is_active('https://wikipedia.org', timeout, if not site_is_active('https://wikipedia.org', timeout,
@ -4393,7 +4393,7 @@ def _test_danger_svg(base_dir: str) -> None:
domain_full = domain domain_full = domain
onion_domain = None onion_domain = None
i2p_domain = None i2p_domain = None
federation_list = [] federation_list: list[str] = []
debug = True debug = True
svg_image_filename = base_dir + '/.unit_test_safe.svg' svg_image_filename = base_dir + '/.unit_test_safe.svg'
post_json_object = { post_json_object = {
@ -4801,7 +4801,7 @@ def _test_hashtag_rules():
conditions_str = \ conditions_str = \
'contains "Cat" or contains "Corvid" or ' + \ 'contains "Cat" or contains "Corvid" or ' + \
'contains "Dormouse" or contains "Buzzard"' 'contains "Dormouse" or contains "Buzzard"'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == str(['or', ['contains', ['"Cat"']], assert str(tree) == str(['or', ['contains', ['"Cat"']],
@ -4812,7 +4812,7 @@ def _test_hashtag_rules():
content = 'This is a test' content = 'This is a test'
moderated = True moderated = True
conditions_str = '#foo or #bar' conditions_str = '#foo or #bar'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == str(['or', ['#foo'], ['#bar']]) assert str(tree) == str(['or', ['#foo'], ['#bar']])
@ -4826,7 +4826,7 @@ def _test_hashtag_rules():
url = 'https://testsite.com/something' url = 'https://testsite.com/something'
moderated = True moderated = True
conditions_str = '#foo and from "testsite.com"' conditions_str = '#foo and from "testsite.com"'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == str(['and', ['#foo'], ['from', ['"testsite.com"']]]) assert str(tree) == str(['and', ['#foo'], ['from', ['"testsite.com"']]])
@ -4839,7 +4839,7 @@ def _test_hashtag_rules():
content = 'This is a test' content = 'This is a test'
moderated = True moderated = True
conditions_str = 'contains "is a" and #foo or #bar' conditions_str = 'contains "is a" and #foo or #bar'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == \ assert str(tree) == \
@ -4853,7 +4853,7 @@ def _test_hashtag_rules():
moderated = False moderated = False
conditions_str = 'not moderated and #foo or #bar' conditions_str = 'not moderated and #foo or #bar'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == \ assert str(tree) == \
@ -4866,7 +4866,7 @@ def _test_hashtag_rules():
moderated = True moderated = True
conditions_str = 'moderated and #foo or #bar' conditions_str = 'moderated and #foo or #bar'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == \ assert str(tree) == \
@ -4878,7 +4878,7 @@ def _test_hashtag_rules():
assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url) assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url)
conditions_str = 'x' conditions_str = 'x'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert tree is None assert tree is None
@ -4887,7 +4887,7 @@ def _test_hashtag_rules():
assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url) assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url)
conditions_str = '#x' conditions_str = '#x'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == str(['#x']) assert str(tree) == str(['#x'])
@ -4898,7 +4898,7 @@ def _test_hashtag_rules():
assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url) assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url)
conditions_str = 'not #b' conditions_str = 'not #b'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == str(['not', ['#b']]) assert str(tree) == str(['not', ['#b']])
@ -4909,7 +4909,7 @@ def _test_hashtag_rules():
assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url) assert not hashtag_rule_resolve(tree, hashtags, moderated, content, url)
conditions_str = '#foo or #bar and #a' conditions_str = '#foo or #bar and #a'
tags_in_conditions = [] tags_in_conditions: list[str] = []
tree = hashtag_rule_tree(operators, conditions_str, tree = hashtag_rule_tree(operators, conditions_str,
tags_in_conditions, moderated) tags_in_conditions, moderated)
assert str(tree) == str(['and', ['or', ['#foo'], ['#bar']], ['#a']]) assert str(tree) == str(['and', ['or', ['#foo'], ['#bar']], ['#a']])
@ -5062,7 +5062,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
chat_url = '' chat_url = ''
auto_cw_cache = {} auto_cw_cache = {}
video_transcript = '' video_transcript = ''
searchable_by = [] searchable_by: list[str] = []
session = None session = None
reply = \ reply = \
create_public_post(base_dir, nickname, domain, port, http_prefix, create_public_post(base_dir, nickname, domain, port, http_prefix,
@ -5139,7 +5139,7 @@ def get_function_calls(name: str, lines: [], start_line_ctr: int,
"""Returns the functions called by the given one, """Returns the functions called by the given one,
Starting with the given source code at the given line Starting with the given source code at the given line
""" """
calls_functions = [] calls_functions: list[str] = []
function_content_str = '' function_content_str = ''
for line_ctr in range(start_line_ctr + 1, len(lines)): for line_ctr in range(start_line_ctr + 1, len(lines)):
line_str = lines[line_ctr].strip() line_str = lines[line_ctr].strip()
@ -5423,7 +5423,7 @@ def _test_checkbox_names():
def _test_post_field_names(source_file: str, fieldnames: []): def _test_post_field_names(source_file: str, fieldnames: []):
print('test_post_field_Names') print('test_post_field_Names')
fnames = [] fnames: list[str] = []
for field in fieldnames: for field in fieldnames:
fnames.append(field + '.get') fnames.append(field + '.get')
@ -5459,7 +5459,7 @@ def _test_post_field_names(source_file: str, fieldnames: []):
' should be camel case') ' should be camel case')
assert False assert False
fnames = [] fnames: list[str] = []
for field in fieldnames: for field in fieldnames:
fnames.append(field + '[') fnames.append(field + '[')
for fname in fnames: for fname in fnames:
@ -5492,7 +5492,7 @@ def _test_post_field_names(source_file: str, fieldnames: []):
def _test_thread_functions(): def _test_thread_functions():
print('test_thread_functions') print('test_thread_functions')
modules = {} modules = {}
threads_called_in_modules = [] threads_called_in_modules: list[str] = []
# get the source for each module # get the source for each module
# Allow recursive walk # Allow recursive walk
@ -5565,7 +5565,7 @@ def _test_thread_functions():
ctr += 1 ctr += 1
continue continue
arg_ctr = 0 arg_ctr = 0
calling_function_args_list = [] calling_function_args_list: list[str] = []
for func_arg in thread_function_args: for func_arg in thread_function_args:
if arg_ctr == 0: if arg_ctr == 0:
arg_ctr += 1 arg_ctr += 1
@ -5607,7 +5607,7 @@ def _check_self_variables(mod_name: str, method_name: str,
self_vars = line.split('self.server.') self_vars = line.split('self.server.')
ctr = 0 ctr = 0
terminators = (' ', '.', ',', ')', '[', ' ', ':') terminators = (' ', '.', ',', ')', '[', ' ', ':')
func_args = [] func_args: list[str] = []
for arg_str in method_args: for arg_str in method_args:
arg_str = arg_str.strip().split(':')[0] arg_str = arg_str.strip().split(':')[0]
func_args.append(arg_str) func_args.append(arg_str)
@ -5631,7 +5631,7 @@ def _test_functions():
function_properties = {} function_properties = {}
modules = {} modules = {}
mod_groups = {} mod_groups = {}
method_loc = [] method_loc: list[str] = []
for _, _, files in os.walk('.'): for _, _, files in os.walk('.'):
for source_file in files: for source_file in files:
@ -5659,7 +5659,7 @@ def _test_functions():
line_count = 0 line_count = 0
prev_line = 'start' prev_line = 'start'
method_name = '' method_name = ''
method_args = [] method_args: list[str] = []
module_line = 0 module_line = 0
curr_return_types = '' curr_return_types = ''
is_comment = False is_comment = False
@ -5761,7 +5761,7 @@ def _test_functions():
not return_types.endswith(')'): not return_types.endswith(')'):
return_types += ')' return_types += ')'
else: else:
return_types = [] return_types: list[str] = []
curr_return_types = return_types curr_return_types = return_types
method_args = method_args.split(')', 1)[0] method_args = method_args.split(')', 1)[0]
method_args = method_args.replace(' ', '').split(',') method_args = method_args.replace(' ', '').split(',')
@ -5807,7 +5807,7 @@ def _test_functions():
'get' 'get'
] ]
bad_function_names = [] bad_function_names: list[str] = []
for name, properties in function_properties.items(): for name, properties in function_properties.items():
if '_' not in name: if '_' not in name:
if name.lower() != name: if name.lower() != name:
@ -6109,7 +6109,7 @@ def _test_links_within_post(base_dir: str) -> None:
chat_url = '' chat_url = ''
auto_cw_cache = {} auto_cw_cache = {}
video_transcript = '' video_transcript = ''
searchable_by = [] searchable_by: list[str] = []
session = None session = None
post_json_object = \ post_json_object = \
@ -6464,7 +6464,7 @@ def _test_speaker_replace_link():
'not run more than one snowflake in the same ' + \ 'not run more than one snowflake in the same ' + \
'network.https://support.torproject.org/censorship/' + \ 'network.https://support.torproject.org/censorship/' + \
'how-to-help-running-snowflake/' 'how-to-help-running-snowflake/'
detected_links = [] detected_links: list[str] = []
result = \ result = \
speaker_replace_links(http_prefix, nickname, domain, domain_full, speaker_replace_links(http_prefix, nickname, domain, domain_full,
text, {'Linked': 'Web link'}, detected_links) text, {'Linked': 'Web link'}, detected_links)
@ -6476,7 +6476,7 @@ def _test_speaker_replace_link():
remote_link = 'https://somedomain/tags/sometag' remote_link = 'https://somedomain/tags/sometag'
text = 'Test with a hashtag ' + remote_link + ' link' text = 'Test with a hashtag ' + remote_link + ' link'
detected_links = [] detected_links: list[str] = []
result = \ result = \
speaker_replace_links(http_prefix, nickname, domain, domain_full, speaker_replace_links(http_prefix, nickname, domain, domain_full,
text, {'Linked': 'Web link'}, detected_links) text, {'Linked': 'Web link'}, detected_links)
@ -6550,7 +6550,7 @@ def test_update_actor(base_dir: str):
http_prefix = 'http' http_prefix = 'http'
proxy_type = None proxy_type = None
federation_list = [] federation_list: list[str] = []
system_language = 'en' system_language = 'en'
if os.path.isdir(base_dir + '/.tests'): if os.path.isdir(base_dir + '/.tests'):
@ -6627,7 +6627,7 @@ def test_update_actor(base_dir: str):
'=gv5G\n' + \ '=gv5G\n' + \
'-----END PGP PUBLIC KEY BLOCK-----' '-----END PGP PUBLIC KEY BLOCK-----'
signing_priv_key_pem = None signing_priv_key_pem = None
mitm_servers = [] mitm_servers: list[str] = []
actor_update = \ actor_update = \
pgp_public_key_upload(alice_dir, session_alice, pgp_public_key_upload(alice_dir, session_alice,
'alice', password, 'alice', password,
@ -6734,7 +6734,7 @@ def _test_spoofed_geolocation() -> None:
assert not point_in_nogo(test_square, 5, 11) assert not point_in_nogo(test_square, 5, 11)
assert not point_in_nogo(test_square, -5, -5) assert not point_in_nogo(test_square, -5, -5)
assert not point_in_nogo(test_square, -5, 5) assert not point_in_nogo(test_square, -5, 5)
nogo_list = [] nogo_list: list[str] = []
curr_time = date_utcnow() curr_time = date_utcnow()
decoy_seed = 7634681 decoy_seed = 7634681
city_radius = 0.1 city_radius = 0.1
@ -6749,7 +6749,7 @@ def _test_spoofed_geolocation() -> None:
assert len(coords[4]) > 4 assert len(coords[4]) > 4
assert len(coords[5]) > 4 assert len(coords[5]) > 4
assert coords[6] > 0 assert coords[6] > 0
nogo_list = [] nogo_list: list[str] = []
coords = spoof_geolocation('', 'unknown', curr_time, coords = spoof_geolocation('', 'unknown', curr_time,
decoy_seed, cities_list, nogo_list) decoy_seed, cities_list, nogo_list)
assert coords[0] >= 51.8744 - city_radius assert coords[0] >= 51.8744 - city_radius
@ -7232,7 +7232,7 @@ def _translate_ontology(base_dir: str) -> None:
if "rdfs:label" not in item: if "rdfs:label" not in item:
continue continue
english_str = None english_str = None
languages_found = [] languages_found: list[str] = []
for label in item["rdfs:label"]: for label in item["rdfs:label"]:
if '@language' not in label: if '@language' not in label:
continue continue
@ -7302,7 +7302,7 @@ def _test_can_replyto(base_dir: str) -> None:
chat_url = '' chat_url = ''
auto_cw_cache = {} auto_cw_cache = {}
video_transcript = '' video_transcript = ''
searchable_by = [] searchable_by: list[str] = []
session = None session = None
post_json_object = \ post_json_object = \
@ -8642,7 +8642,7 @@ def _test_book_link(base_dir: str):
'type': 'Edition'}], 'type': 'Edition'}],
'to': ['https://www.w3.org/ns/activitystreams#Public'], 'to': ['https://www.w3.org/ns/activitystreams#Public'],
'type': 'Note'} 'type': 'Note'}
languages_understood = [] languages_understood: list[str] = []
translate = {} translate = {}
book_dict = get_book_from_post(post_json_object, True) book_dict = get_book_from_post(post_json_object, True)

View File

@ -141,7 +141,7 @@ def get_themes_list(base_dir: str) -> []:
also used to create the web interface dropdown list also used to create the web interface dropdown list
and to lookup function names and to lookup function names
""" """
themes = [] themes: list[str] = []
for _, dirs, _ in os.walk(base_dir + '/theme'): for _, dirs, _ in os.walk(base_dir + '/theme'):
for theme_name in dirs: for theme_name in dirs:
if '~' not in theme_name and \ if '~' not in theme_name and \

2
tox.py
View File

@ -77,7 +77,7 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None:
not_tox_address = True not_tox_address = True
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment']: list[dict] = []
# remove any existing value # remove any existing value
property_found = None property_found = None

View File

@ -385,7 +385,7 @@ def get_actor_languages_list(actor_json: {}) -> []:
return lang_list return lang_list
if isinstance(property_value[prop_value_name], str): if isinstance(property_value[prop_value_name], str):
lang_str = property_value[prop_value_name] lang_str = property_value[prop_value_name]
lang_list_temp = [] lang_list_temp: list[str] = []
if ',' in lang_str: if ',' in lang_str:
lang_list_temp = lang_str.split(',') lang_list_temp = lang_str.split(',')
elif ';' in lang_str: elif ';' in lang_str:
@ -398,7 +398,7 @@ def get_actor_languages_list(actor_json: {}) -> []:
lang_list_temp = lang_str.split(' ') lang_list_temp = lang_str.split(' ')
else: else:
return [lang_str] return [lang_str]
lang_list = [] lang_list: list[str] = []
for lang in lang_list_temp: for lang in lang_list_temp:
lang = lang.strip() lang = lang.strip()
if lang not in lang_list: if lang not in lang_list:
@ -1083,7 +1083,7 @@ def get_followers_list(base_dir: str,
if not os.path.isfile(filename): if not os.path.isfile(filename):
return [] return []
lines = [] lines: list[str] = []
try: try:
with open(filename, 'r', encoding='utf-8') as fp_foll: with open(filename, 'r', encoding='utf-8') as fp_foll:
lines = fp_foll.readlines() lines = fp_foll.readlines()
@ -1103,7 +1103,7 @@ def get_followers_of_person(base_dir: str,
"""Returns a list containing the followers of the given person """Returns a list containing the followers of the given person
Used by the shared inbox to know who to send incoming mail to Used by the shared inbox to know who to send incoming mail to
""" """
followers = [] followers: list[str] = []
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
handle = nickname + '@' + domain handle = nickname + '@' + domain
handle_dir = acct_handle_dir(base_dir, handle) handle_dir = acct_handle_dir(base_dir, handle)
@ -2249,7 +2249,7 @@ def _remove_attachment(base_dir: str, http_prefix: str, domain: str,
except OSError: except OSError:
print('EX: _remove_attachment unable to delete etag file ' + print('EX: _remove_attachment unable to delete etag file ' +
str(etag_filename)) str(etag_filename))
post_json['attachment'] = [] post_json['attachment']: list[dict] = []
def remove_post_from_index(post_url: str, debug: bool, def remove_post_from_index(post_url: str, debug: bool,
@ -2261,7 +2261,7 @@ def remove_post_from_index(post_url: str, debug: bool,
post_id = remove_id_ending(post_url) post_id = remove_id_ending(post_url)
if not text_in_file(post_id, index_file): if not text_in_file(post_id, index_file):
return return
lines = [] lines: list[str] = []
try: try:
with open(index_file, 'r', encoding='utf-8') as fp_mod1: with open(index_file, 'r', encoding='utf-8') as fp_mod1:
lines = fp_mod1.readlines() lines = fp_mod1.readlines()
@ -3009,7 +3009,7 @@ def _search_virtual_box_posts(base_dir: str, nickname: str, domain: str,
else: else:
search_words = [search_str] search_words = [search_str]
res = [] res: list[str] = []
try: try:
with open(index_filename, 'r', encoding='utf-8') as fp_index: with open(index_filename, 'r', encoding='utf-8') as fp_index:
post_filename = 'start' post_filename = 'start'
@ -3051,7 +3051,7 @@ def _get_mutuals_of_person(base_dir: str,
get_followers_list(base_dir, nickname, domain, 'followers.txt') get_followers_list(base_dir, nickname, domain, 'followers.txt')
following = \ following = \
get_followers_list(base_dir, nickname, domain, 'following.txt') get_followers_list(base_dir, nickname, domain, 'following.txt')
mutuals = [] mutuals: list[str] = []
for handle in following: for handle in following:
if handle in followers: if handle in followers:
mutuals.append(handle) mutuals.append(handle)
@ -3101,8 +3101,8 @@ def search_box_posts(base_dir: str, nickname: str, domain: str,
else: else:
search_words = [search_str] search_words = [search_str]
following_list = [] following_list: list[str] = []
mutuals_list = [] mutuals_list: list[str] = []
check_searchable_by = False check_searchable_by = False
if box_name == 'inbox': if box_name == 'inbox':
check_searchable_by = True check_searchable_by = True
@ -3114,7 +3114,7 @@ def search_box_posts(base_dir: str, nickname: str, domain: str,
# create a list containing all of the mutuals # create a list containing all of the mutuals
mutuals_list = _get_mutuals_of_person(base_dir, nickname, domain) mutuals_list = _get_mutuals_of_person(base_dir, nickname, domain)
res = [] res: list[str] = []
for root, _, fnames in os.walk(path): for root, _, fnames in os.walk(path):
for fname in fnames: for fname in fnames:
file_path = os.path.join(root, fname) file_path = os.path.join(root, fname)
@ -3979,7 +3979,7 @@ def get_supported_languages(base_dir: str) -> []:
"""Returns a list of supported languages """Returns a list of supported languages
""" """
translations_dir = base_dir + '/translations' translations_dir = base_dir + '/translations'
languages_str = [] languages_str: list[str] = []
for _, _, files in os.walk(translations_dir): for _, _, files in os.walk(translations_dir):
for fname in files: for fname in files:
if not fname.endswith('.json'): if not fname.endswith('.json'):
@ -3995,7 +3995,7 @@ def get_category_types(base_dir: str) -> []:
"""Returns the list of ontologies """Returns the list of ontologies
""" """
ontology_dir = base_dir + '/ontology' ontology_dir = base_dir + '/ontology'
categories = [] categories: list[str] = []
for _, _, files in os.walk(ontology_dir): for _, _, files in os.walk(ontology_dir):
for fname in files: for fname in files:
if not fname.endswith('.json'): if not fname.endswith('.json'):
@ -4511,7 +4511,7 @@ def load_min_images_for_accounts(base_dir: str) -> []:
"""Loads a list of nicknames for accounts where all images should """Loads a list of nicknames for accounts where all images should
be minimized by default be minimized by default
""" """
min_images_for_accounts = [] min_images_for_accounts: list[str] = []
dir_str = data_dir(base_dir) dir_str = data_dir(base_dir)
for subdir, dirs, _ in os.walk(dir_str): for subdir, dirs, _ in os.walk(dir_str):
for account in dirs: for account in dirs:
@ -4556,7 +4556,7 @@ def load_reverse_timeline(base_dir: str) -> []:
"""Loads flags for each user indicating whether they prefer to """Loads flags for each user indicating whether they prefer to
see reversed timelines see reversed timelines
""" """
reverse_sequence = [] reverse_sequence: list[str] = []
dir_str = data_dir(base_dir) dir_str = data_dir(base_dir)
for _, dirs, _ in os.walk(dir_str): for _, dirs, _ in os.walk(dir_str):
for acct in dirs: for acct in dirs:
@ -5368,7 +5368,7 @@ def load_mitm_servers(base_dir: str) -> []:
"""Loads a list of servers implementing insecure transport security """Loads a list of servers implementing insecure transport security
""" """
mitm_servers_filename = data_dir(base_dir) + '/mitm_servers.txt' mitm_servers_filename = data_dir(base_dir) + '/mitm_servers.txt'
mitm_servers = [] mitm_servers: list[str] = []
if os.path.isfile(mitm_servers_filename): if os.path.isfile(mitm_servers_filename):
try: try:
with open(mitm_servers_filename, 'r', with open(mitm_servers_filename, 'r',

View File

@ -54,7 +54,7 @@ def _get_left_column_shares(base_dir: str,
if not shares_json: if not shares_json:
return [] return []
links_list = [] links_list: list[str] = []
ctr = 0 ctr = 0
for _, item in shares_json.items(): for _, item in shares_json.items():
sharedesc = item['displayName'] sharedesc = item['displayName']
@ -97,7 +97,7 @@ def _get_left_column_wanted(base_dir: str,
if not shares_json: if not shares_json:
return [] return []
links_list = [] links_list: list[str] = []
ctr = 0 ctr = 0
for _, item in shares_json.items(): for _, item in shares_json.items():
sharedesc = item['displayName'] sharedesc = item['displayName']
@ -404,7 +404,7 @@ def html_links_mobile(base_dir: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -478,7 +478,7 @@ def html_edit_links(translate: {}, base_dir: str, path: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
edit_links_form = \ edit_links_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -380,10 +380,10 @@ def html_citations(base_dir: str, nickname: str, domain: str,
# these can then be used to re-select checkboxes later # these can then be used to re-select checkboxes later
citations_filename = \ citations_filename = \
acct_dir(base_dir, nickname, domain) + '/.citations.txt' acct_dir(base_dir, nickname, domain) + '/.citations.txt'
citations_selected = [] citations_selected: list[str] = []
if os.path.isfile(citations_filename): if os.path.isfile(citations_filename):
citations_separator = '#####' citations_separator = '#####'
citations = [] citations: list[str] = []
try: try:
with open(citations_filename, 'r', encoding='utf-8') as fp_cit: with open(citations_filename, 'r', encoding='utf-8') as fp_cit:
citations = fp_cit.readlines() citations = fp_cit.readlines()
@ -406,7 +406,7 @@ def html_citations(base_dir: str, nickname: str, domain: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -527,7 +527,7 @@ def html_newswire_mobile(base_dir: str, nickname: str,
metadata = None metadata = None
if text_mode_browser(ua_str): if text_mode_browser(ua_str):
metadata = '<meta http-equiv="refresh" content="1800" >\n' metadata = '<meta http-equiv="refresh" content="1800" >\n'
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, metadata, html_header_with_external_style(css_filename, instance_title, metadata,
preload_images) preload_images)
@ -603,7 +603,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
edit_newswire_form = \ edit_newswire_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -761,7 +761,7 @@ def html_edit_news_post(translate: {}, base_dir: str, path: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
edit_news_post_form = \ edit_news_post_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -74,7 +74,7 @@ def html_confirm_delete(server,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
delete_post_str = \ delete_post_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -171,7 +171,7 @@ def html_confirm_remove_shared_item(translate: {},
css_filename = base_dir + '/follow.css' css_filename = base_dir + '/follow.css'
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
shares_str = html_header_with_external_style(css_filename, shares_str = html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) preload_images)
@ -229,7 +229,7 @@ def html_confirm_follow(translate: {}, base_dir: str,
css_filename = base_dir + '/follow.css' css_filename = base_dir + '/follow.css'
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
follow_str = html_header_with_external_style(css_filename, follow_str = html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) preload_images)
@ -290,7 +290,7 @@ def html_confirm_unfollow(translate: {}, base_dir: str,
css_filename = base_dir + '/follow.css' css_filename = base_dir + '/follow.css'
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
follow_str = html_header_with_external_style(css_filename, follow_str = html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) preload_images)
@ -339,7 +339,7 @@ def html_confirm_unblock(translate: {}, base_dir: str,
css_filename = base_dir + '/follow.css' css_filename = base_dir + '/follow.css'
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
block_str = html_header_with_external_style(css_filename, block_str = html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) preload_images)
@ -388,7 +388,7 @@ def html_confirm_block(translate: {}, base_dir: str,
css_filename = base_dir + '/follow.css' css_filename = base_dir + '/follow.css'
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
block_str = html_header_with_external_style(css_filename, block_str = html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) preload_images)

View File

@ -75,7 +75,7 @@ def html_conversation_view(authorized: bool, post_id: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
metadata_str = '' metadata_str = ''
if post_id: if post_id:

View File

@ -791,7 +791,7 @@ def html_new_post(edit_post_params: {},
currencies = get_currencies() currencies = get_currencies()
extra_fields += ' <select id="themeDropdown" ' + \ extra_fields += ' <select id="themeDropdown" ' + \
'name="itemCurrency" class="theme">\n' 'name="itemCurrency" class="theme">\n'
currency_list = [] currency_list: list[str] = []
for symbol, curr_name in currencies.items(): for symbol, curr_name in currencies.items():
currency_list.append(curr_name + ' ' + symbol) currency_list.append(curr_name + ' ' + symbol)
currency_list.sort() currency_list.sort()
@ -858,7 +858,7 @@ def html_new_post(edit_post_params: {},
currencies = get_currencies() currencies = get_currencies()
extra_fields += ' <select id="themeDropdown" ' + \ extra_fields += ' <select id="themeDropdown" ' + \
'name="itemCurrency" class="theme">\n' 'name="itemCurrency" class="theme">\n'
currency_list = [] currency_list: list[str] = []
for symbol, curr_name in currencies.items(): for symbol, curr_name in currencies.items():
currency_list.append(curr_name + ' ' + symbol) currency_list.append(curr_name + ' ' + symbol)
currency_list.sort() currency_list.sort()
@ -922,7 +922,7 @@ def html_new_post(edit_post_params: {},
translate['Citations'] + ':</label></p>\n' translate['Citations'] + ':</label></p>\n'
citations_str += ' <ul>\n' citations_str += ' <ul>\n'
citations_separator = '#####' citations_separator = '#####'
citations = [] citations: list[str] = []
try: try:
with open(citations_filename, 'r', with open(citations_filename, 'r',
encoding='utf-8') as fp_cit: encoding='utf-8') as fp_cit:

View File

@ -236,7 +236,7 @@ def html_front_screen(signing_priv_key_pem: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
profile_str = \ profile_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) + \ preload_images) + \

View File

@ -93,9 +93,9 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str:
days_since_epoch_str = str(days_since_epoch) + ' ' days_since_epoch_str = str(days_since_epoch) + ' '
days_since_epoch_str2 = str(days_since_epoch - 1) + ' ' days_since_epoch_str2 = str(days_since_epoch - 1) + ' '
recently = days_since_epoch - 1 recently = days_since_epoch - 1
tag_swarm = [] tag_swarm: list[str] = []
category_swarm = [] category_swarm: list[str] = []
swarm_map = [] swarm_map: list[str] = []
domain_histogram = {} domain_histogram = {}
# Load the blocked hashtags into memory. # Load the blocked hashtags into memory.
@ -269,7 +269,7 @@ def html_search_hashtag_category(translate: {},
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -385,7 +385,7 @@ def store_hash_tags(base_dir: str, nickname: str, domain: str,
# obtain any map links and these can be associated with hashtags # obtain any map links and these can be associated with hashtags
# get geolocations from content # get geolocations from content
map_links = [] map_links: list[str] = []
published = None published = None
if 'content' in post_json_object['object']: if 'content' in post_json_object['object']:
published = post_json_object['object']['published'] published = post_json_object['object']['published']

View File

@ -54,7 +54,7 @@ def html_likers_of_post(base_dir: str, nickname: str,
css_filename = base_dir + '/epicyon.css' css_filename = base_dir + '/epicyon.css'
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -123,7 +123,7 @@ def html_account_info(translate: {},
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
info_form = \ info_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -173,7 +173,7 @@ def html_account_info(translate: {},
'followers', session, 'followers', session,
http_prefix, search_actor, 1, 5, debug, http_prefix, search_actor, 1, 5, debug,
mitm_servers) mitm_servers)
blocked_followers = [] blocked_followers: list[str] = []
for follower_actor in followers_list: for follower_actor in followers_list:
follower_nickname = get_nickname_from_actor(follower_actor) follower_nickname = get_nickname_from_actor(follower_actor)
if not follower_nickname: if not follower_nickname:
@ -193,7 +193,7 @@ def html_account_info(translate: {},
'following', session, 'following', session,
http_prefix, search_actor, 1, 5, debug, http_prefix, search_actor, 1, 5, debug,
mitm_servers) mitm_servers)
blocked_following = [] blocked_following: list[str] = []
for following_actor in following_list: for following_actor in following_list:
following_nickname = get_nickname_from_actor(following_actor) following_nickname = get_nickname_from_actor(following_actor)
if not following_nickname: if not following_nickname:
@ -346,7 +346,7 @@ def html_moderation_info(translate: {}, base_dir: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
info_form = html_header_with_external_style(css_filename, info_form = html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) preload_images)
@ -373,7 +373,7 @@ def html_moderation_info(translate: {}, base_dir: str,
info_shown = False info_shown = False
accounts = [] accounts: list[str] = []
dir_str = data_dir(base_dir) dir_str = data_dir(base_dir)
for _, dirs, _ in os.walk(dir_str): for _, dirs, _ in os.walk(dir_str):
for acct in dirs: for acct in dirs:

View File

@ -325,7 +325,7 @@ def html_podcast_episode(translate: {},
dir_str + '/podcast-background.jpg') dir_str + '/podcast-background.jpg')
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
podcast_str = \ podcast_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -472,7 +472,7 @@ def html_podcast_episode(translate: {},
'<p><a href="' + fediverse_handle + '">@' + \ '<p><a href="' + fediverse_handle + '">@' + \
podcast_nickname + '@' + podcast_domain + '</a></p>\n' podcast_nickname + '@' + podcast_domain + '</a></p>\n'
extra_links = [] extra_links: list[str] = []
if len(newswire_item) > 10: if len(newswire_item) > 10:
extra_links = newswire_item[10] extra_links = newswire_item[10]
if extra_links: if extra_links:

View File

@ -1938,7 +1938,7 @@ def _substitute_onion_domains(base_dir: str, content: str) -> str:
onion_domains_filename = data_dir(base_dir) + '/onion_domains.txt' onion_domains_filename = data_dir(base_dir) + '/onion_domains.txt'
if os.path.isfile(onion_domains_filename): if os.path.isfile(onion_domains_filename):
onion_domains_list = [] onion_domains_list: list[str] = []
try: try:
with open(onion_domains_filename, 'r', with open(onion_domains_filename, 'r',
encoding='utf-8') as fp_onions: encoding='utf-8') as fp_onions:
@ -2300,7 +2300,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
person_url = local_actor_url(http_prefix, nickname, domain_full) person_url = local_actor_url(http_prefix, nickname, domain_full)
actor_json = \ actor_json = \
get_person_from_cache(base_dir, person_url, person_cache) get_person_from_cache(base_dir, person_url, person_cache)
languages_understood = [] languages_understood: list[str] = []
if actor_json: if actor_json:
languages_understood = get_actor_languages_list(actor_json) languages_understood = get_actor_languages_list(actor_json)
@ -2311,7 +2311,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
if post_json_object['type'] == 'Announce': if post_json_object['type'] == 'Announce':
announce_json_object = post_json_object.copy() announce_json_object = post_json_object.copy()
blocked_cache = {} blocked_cache = {}
block_federated = [] block_federated: list[str] = []
show_vote_posts = True show_vote_posts = True
show_vote_file = acct_dir(base_dir, nickname, domain) + '/.noVotes' show_vote_file = acct_dir(base_dir, nickname, domain) + '/.noVotes'
if os.path.isfile(show_vote_file): if os.path.isfile(show_vote_file):
@ -2841,7 +2841,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
buy_str = '' buy_str = ''
post_attachments = get_post_attachments(post_json_object['object']) post_attachments = get_post_attachments(post_json_object['object'])
if not post_attachments: if not post_attachments:
post_json_object['object']['attachment'] = [] post_json_object['object']['attachment']: list[dict] = []
if not is_patch: if not is_patch:
buy_links = get_buy_links(post_json_object, translate, buy_sites) buy_links = get_buy_links(post_json_object, translate, buy_sites)
buy_str = _get_buy_footer(buy_links, translate) buy_str = _get_buy_footer(buy_links, translate)
@ -3325,7 +3325,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
' <link rel="author" ' + \ ' <link rel="author" ' + \
'type="application/activity+json" ' + \ 'type="application/activity+json" ' + \
'href="' + actor + '" />\n' 'href="' + actor + '" />\n'
preload_images = [] preload_images: list[str] = []
header_str = html_header_with_external_style(css_filename, header_str = html_header_with_external_style(css_filename,
instance_title, metadata_str, instance_title, metadata_str,
preload_images) preload_images)
@ -3393,7 +3393,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
metadata = '' metadata = ''
preload_images = [] preload_images: list[str] = []
header_str = \ header_str = \
html_header_with_external_style(css_filename, instance_title, metadata, html_header_with_external_style(css_filename, instance_title, metadata,
preload_images) preload_images)
@ -3486,7 +3486,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
metadata = '' metadata = ''
preload_images = [] preload_images: list[str] = []
header_str = \ header_str = \
html_header_with_external_style(css_filename, instance_title, metadata, html_header_with_external_style(css_filename, instance_title, metadata,
preload_images) preload_images)

View File

@ -187,7 +187,7 @@ def _valid_profile_preview_post(post_json_object: {},
if not post_json_object.get('id'): if not post_json_object.get('id'):
return False, None return False, None
# wrap in create # wrap in create
cc_list = [] cc_list: list[str] = []
if post_json_object.get('cc'): if post_json_object.get('cc'):
cc_list = post_json_object['cc'] cc_list = post_json_object['cc']
new_post_json_object = { new_post_json_object = {
@ -632,7 +632,7 @@ def html_profile_after_search(authorized: bool,
profile_str = text_mode_removals(profile_str, translate) profile_str = text_mode_removals(profile_str, translate)
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
return html_header_with_external_style(css_filename, return html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) + \ preload_images) + \
@ -1056,7 +1056,7 @@ def html_profile(signing_priv_key_pem: str,
if not nickname: if not nickname:
return "" return ""
if is_system_account(nickname): if is_system_account(nickname):
min_images_for_accounts = [] min_images_for_accounts: list[str] = []
return html_front_screen(signing_priv_key_pem, return html_front_screen(signing_priv_key_pem,
rss_icon_at_top, rss_icon_at_top,
icons_as_buttons, icons_as_buttons,
@ -1630,7 +1630,7 @@ def html_profile(signing_priv_key_pem: str,
if selected == 'posts' and not premium: if selected == 'posts' and not premium:
max_profile_posts = \ max_profile_posts = \
get_max_profile_posts(base_dir, nickname, domain, 20) get_max_profile_posts(base_dir, nickname, domain, 20)
min_images_for_accounts = [] min_images_for_accounts: list[str] = []
profile_str += \ profile_str += \
_html_profile_posts(recent_posts_cache, max_profile_posts, _html_profile_posts(recent_posts_cache, max_profile_posts,
translate, translate,
@ -1791,7 +1791,7 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
break break
if len(outbox_feed['orderedItems']) == 0: if len(outbox_feed['orderedItems']) == 0:
break break
shown_items = [] shown_items: list[str] = []
for item in outbox_feed['orderedItems']: for item in outbox_feed['orderedItems']:
if item['type'] == 'Create': if item['type'] == 'Create':
if not item['object'].get('id'): if not item['object'].get('id'):
@ -2545,7 +2545,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
locations_filename = base_dir + '/custom_locations.txt' locations_filename = base_dir + '/custom_locations.txt'
if not os.path.isfile(locations_filename): if not os.path.isfile(locations_filename):
locations_filename = base_dir + '/locations.txt' locations_filename = base_dir + '/locations.txt'
cities = [] cities: list[str] = []
try: try:
with open(locations_filename, 'r', encoding='utf-8') as fp_loc: with open(locations_filename, 'r', encoding='utf-8') as fp_loc:
cities = fp_loc.readlines() cities = fp_loc.readlines()
@ -3474,7 +3474,7 @@ def html_edit_profile(server, translate: {},
system_monitor_str = _html_system_monitor(nickname, translate) system_monitor_str = _html_system_monitor(nickname, translate)
instance_title = get_config_param(base_dir, 'instanceTitle') instance_title = get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
edit_profile_form = \ edit_profile_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -79,7 +79,7 @@ def html_search_emoji(translate: {}, base_dir: str, search_str: str,
# create header # create header
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
emoji_form = \ emoji_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -281,7 +281,7 @@ def html_search_shared_items(translate: {},
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
shared_items_form = \ shared_items_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -409,7 +409,7 @@ def html_search_emoji_text_entry(translate: {},
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
emoji_str = \ emoji_str = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -560,7 +560,7 @@ def html_skills_search(actor: str, translate: {}, base_dir: str,
skillsearch = skillsearch.lower().strip('\n').strip('\r') skillsearch = skillsearch.lower().strip('\n').strip('\r')
results = [] results: list[str] = []
# search instance accounts # search instance accounts
dir_str = data_dir(base_dir) dir_str = data_dir(base_dir)
for subdir, _, files in os.walk(dir_str + '/'): for subdir, _, files in os.walk(dir_str + '/'):
@ -650,7 +650,7 @@ def html_skills_search(actor: str, translate: {}, base_dir: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
skill_search_form = \ skill_search_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -757,7 +757,7 @@ def html_history_search(translate: {}, base_dir: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
history_search_form = \ history_search_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -909,7 +909,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
nickname = None nickname = None
# read the index # read the index
lines = [] lines: list[str] = []
try: try:
with open(hashtag_index_file, 'r', encoding='utf-8') as fp_hash: with open(hashtag_index_file, 'r', encoding='utf-8') as fp_hash:
lines = fp_hash.readlines() lines = fp_hash.readlines()
@ -936,7 +936,7 @@ def html_hashtag_search(nickname: str, domain: str, port: int,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
hashtag_search_form = \ hashtag_search_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -1145,7 +1145,7 @@ def html_hashtag_search_remote(nickname: str, domain: str, port: int,
get_json(signing_priv_key_pem, get_json(signing_priv_key_pem,
session, hashtag_url_with_page, as_header, None, debug, session, hashtag_url_with_page, as_header, None, debug,
mitm_servers, __version__, http_prefix, domain) mitm_servers, __version__, http_prefix, domain)
lines = [] lines: list[str] = []
if get_json_valid(hashtag_json): if get_json_valid(hashtag_json):
if 'orderedItems' in hashtag_json: if 'orderedItems' in hashtag_json:
lines = hashtag_json['orderedItems'] lines = hashtag_json['orderedItems']
@ -1177,7 +1177,7 @@ def html_hashtag_search_remote(nickname: str, domain: str, port: int,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
hashtag_search_form = \ hashtag_search_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -1343,7 +1343,7 @@ def hashtag_search_rss(nickname: str, domain: str, port: int,
nickname = None nickname = None
# read the index # read the index
lines = [] lines: list[str] = []
try: try:
with open(hashtag_index_file, 'r', encoding='utf-8') as fp_hash: with open(hashtag_index_file, 'r', encoding='utf-8') as fp_hash:
lines = fp_hash.readlines() lines = fp_hash.readlines()
@ -1457,7 +1457,7 @@ def hashtag_search_json(nickname: str, domain: str, port: int,
nickname = None nickname = None
# read the index # read the index
lines = [] lines: list[str] = []
try: try:
with open(hashtag_index_file, 'r', encoding='utf-8') as fp_hash: with open(hashtag_index_file, 'r', encoding='utf-8') as fp_hash:
lines = fp_hash.readlines() lines = fp_hash.readlines()

View File

@ -23,7 +23,7 @@ def html_suspended(base_dir: str) -> str:
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
suspended_form = \ suspended_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -48,7 +48,7 @@ def html_terms_of_service(base_dir: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
tos_form = \ tos_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -112,7 +112,7 @@ def html_following_list(base_dir: str, following_filename: str) -> str:
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
following_list_html = \ following_list_html = \
html_header_with_external_style(css_filename, html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
@ -194,7 +194,7 @@ def html_hashtag_blocked(base_dir: str, translate: {}) -> str:
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
blocked_hashtag_form = \ blocked_hashtag_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)
@ -302,7 +302,7 @@ def _set_actor_property_url(actor_json: {},
"""Sets a url for the given actor property """Sets a url for the given actor property
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment']: list[dict] = []
property_name_lower = property_name.lower() property_name_lower = property_name.lower()
@ -607,7 +607,7 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int,
"""Returns an ActivityStreams collection of ValueFlows Proposal objects """Returns an ActivityStreams collection of ValueFlows Proposal objects
https://codeberg.org/fediverse/fep/src/branch/main/fep/0837/fep-0837.md https://codeberg.org/fediverse/fep/src/branch/main/fep/0837/fep-0837.md
""" """
shares_collection = [] shares_collection: list[dict] = []
shares_json, _ = \ shares_json, _ = \
shares_timeline_json(actor, page_number, items_per_page, shares_timeline_json(actor, page_number, items_per_page,
base_dir, domain, nickname, base_dir, domain, nickname,
@ -770,7 +770,7 @@ def html_header_with_person_markup(css_filename: str, instance_title: str,
https://schema.org/Person https://schema.org/Person
""" """
if not actor_json: if not actor_json:
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
@ -954,7 +954,7 @@ def html_header_with_person_markup(css_filename: str, instance_title: str,
" <meta content=\"" + value + \ " <meta content=\"" + value + \
"\" property=\"og:" + og_tag + "\" />\n" "\" property=\"og:" + og_tag + "\" />\n"
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, html_header_with_external_style(css_filename, instance_title,
og_metadata + profile_markup, og_metadata + profile_markup,
@ -1013,7 +1013,7 @@ def html_header_with_website_markup(css_filename: str, instance_title: str,
'" property="og:locale" />\n' + \ '" property="og:locale" />\n' + \
' <meta content="summary_large_image" property="twitter:card" />\n' ' <meta content="summary_large_image" property="twitter:card" />\n'
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, html_header_with_external_style(css_filename, instance_title,
og_metadata + website_markup, og_metadata + website_markup,
@ -1072,7 +1072,7 @@ def html_header_with_blog_markup(css_filename: str, instance_title: str,
' <meta property="article:modified_time" content="' + \ ' <meta property="article:modified_time" content="' + \
modified + '" />\n' modified + '" />\n'
preload_images = [] preload_images: list[str] = []
html_str = \ html_str = \
html_header_with_external_style(css_filename, instance_title, html_header_with_external_style(css_filename, instance_title,
og_metadata + blog_markup, og_metadata + blog_markup,
@ -1142,7 +1142,7 @@ def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
display_name = replace_strings(display_name, replacements) display_name = replace_strings(display_name, replacements)
# print('TAG: display_name after tags: ' + display_name) # print('TAG: display_name after tags: ' + display_name)
# convert the emoji dictionary to a list # convert the emoji dictionary to a list
emoji_tags_list = [] emoji_tags_list: list[str] = []
for _, tag in emoji_tags.items(): for _, tag in emoji_tags.items():
emoji_tags_list.append(tag) emoji_tags_list.append(tag)
# print('TAG: emoji tags list: ' + str(emoji_tags_list)) # print('TAG: emoji tags list: ' + str(emoji_tags_list))
@ -1276,7 +1276,7 @@ def get_post_attachments_as_html(base_dir: str,
attachment_str = '' attachment_str = ''
attachment_ctr = 0 attachment_ctr = 0
gallery_str = '' gallery_str = ''
attachment_dict = [] attachment_dict: list[dict] = []
# handle peertube-style video posts, where the media links # handle peertube-style video posts, where the media links
# are stored in the url field # are stored in the url field
@ -1312,7 +1312,7 @@ def get_post_attachments_as_html(base_dir: str,
# chat links # chat links
# https://codeberg.org/fediverse/fep/src/branch/main/fep/1970/fep-1970.md # https://codeberg.org/fediverse/fep/src/branch/main/fep/1970/fep-1970.md
attached_urls = [] attached_urls: list[str] = []
for attach in attachment_dict: for attach in attachment_dict:
if not attach.get('type') or \ if not attach.get('type') or \
not attach.get('name') or \ not attach.get('name') or \
@ -2126,7 +2126,7 @@ def html_show_share(base_dir: str, domain: str, nickname: str,
instance_title = \ instance_title = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
preload_images = [] preload_images: list[str] = []
return html_header_with_external_style(css_filename, return html_header_with_external_style(css_filename,
instance_title, None, instance_title, None,
preload_images) + \ preload_images) + \
@ -2260,7 +2260,7 @@ def html_following_data_list(base_dir: str, nickname: str,
petnames_filename = \ petnames_filename = \
acct_dir(base_dir, nickname, domain) + '/petnames.txt' acct_dir(base_dir, nickname, domain) + '/petnames.txt'
if use_petnames and os.path.isfile(petnames_filename): if use_petnames and os.path.isfile(petnames_filename):
following_list = [] following_list: list[str] = []
try: try:
with open(petnames_filename, 'r', with open(petnames_filename, 'r',
encoding='utf-8') as fp_petnames: encoding='utf-8') as fp_petnames:
@ -2316,7 +2316,7 @@ def html_following_dropdown(base_dir: str, nickname: str,
petnames_filename = \ petnames_filename = \
acct_dir(base_dir, nickname, domain) + '/petnames.txt' acct_dir(base_dir, nickname, domain) + '/petnames.txt'
if use_petnames and os.path.isfile(petnames_filename): if use_petnames and os.path.isfile(petnames_filename):
following_list = [] following_list: list[str] = []
try: try:
with open(petnames_filename, 'r', with open(petnames_filename, 'r',
encoding='utf-8') as fp_petnames: encoding='utf-8') as fp_petnames:
@ -2335,7 +2335,7 @@ def html_following_dropdown(base_dir: str, nickname: str,
following_list = msg.split('\n') following_list = msg.split('\n')
list_str += '<option value="" selected></option>\n' list_str += '<option value="" selected></option>\n'
if following_list: if following_list:
domain_sorted_list = [] domain_sorted_list: list[str] = []
for following_address in following_list: for following_address in following_list:
if '@' not in following_address and \ if '@' not in following_address and \
'://' not in following_address: '://' not in following_address:
@ -2368,7 +2368,7 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}:
if not post_attachments: if not post_attachments:
return {} return {}
links = {} links = {}
buy_strings = [] buy_strings: list[str] = []
for buy_str in ('Buy', 'Purchase', 'Subscribe'): for buy_str in ('Buy', 'Purchase', 'Subscribe'):
if translate.get(buy_str): if translate.get(buy_str):
buy_str = translate[buy_str] buy_str = translate[buy_str]

View File

@ -96,7 +96,7 @@ def html_welcome_screen(base_dir: str, nickname: str,
if os.path.isfile(base_dir + '/welcome.css'): if os.path.isfile(base_dir + '/welcome.css'):
css_filename = base_dir + '/welcome.css' css_filename = base_dir + '/welcome.css'
preload_images = [] preload_images: list[str] = []
welcome_form = \ welcome_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -65,7 +65,7 @@ def html_welcome_final(base_dir: str, nickname: str,
if os.path.isfile(base_dir + '/welcome.css'): if os.path.isfile(base_dir + '/welcome.css'):
css_filename = base_dir + '/welcome.css' css_filename = base_dir + '/welcome.css'
preload_images = [] preload_images: list[str] = []
final_form = \ final_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -74,7 +74,7 @@ def html_welcome_profile(base_dir: str, nickname: str, domain: str,
if os.path.isfile(base_dir + '/welcome.css'): if os.path.isfile(base_dir + '/welcome.css'):
css_filename = base_dir + '/welcome.css' css_filename = base_dir + '/welcome.css'
preload_images = [] preload_images: list[str] = []
profile_form = \ profile_form = \
html_header_with_external_style(css_filename, instance_title, None, html_header_with_external_style(css_filename, instance_title, None,
preload_images) preload_images)

View File

@ -528,7 +528,7 @@ def _webfinger_update_from_profile(wf_json: {}, actor_json: {}) -> bool:
"tox": "toxId" "tox": "toxId"
} }
aliases_not_found = [] aliases_not_found: list[str] = []
for name, alias in webfinger_property_name.items(): for name, alias in webfinger_property_name.items():
aliases_not_found.append(alias) aliases_not_found.append(alias)
@ -580,7 +580,7 @@ def _webfinger_update_from_profile(wf_json: {}, actor_json: {}) -> bool:
changed = True changed = True
# remove any aliases which are no longer in the actor profile # remove any aliases which are no longer in the actor profile
remove_alias = [] remove_alias: list[str] = []
for alias in aliases_not_found: for alias in aliases_not_found:
for full_alias in wf_json['aliases']: for full_alias in wf_json['aliases']:
if full_alias.startswith(alias + ':'): if full_alias.startswith(alias + ':'):

View File

@ -117,7 +117,7 @@ def set_website(actor_json: {}, website_url: str, translate: {}) -> None:
not_url = True not_url = True
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment']: list[dict] = []
match_strings = _get_website_strings() match_strings = _get_website_strings()
match_strings.append(translate['Website'].lower()) match_strings.append(translate['Website'].lower())
@ -161,7 +161,7 @@ def set_gemini_link(actor_json: {}, gemini_link: str) -> None:
not_link = True not_link = True
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment']: list[dict] = []
match_strings = _get_gemini_strings() match_strings = _get_gemini_strings()

View File

@ -71,7 +71,7 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
not_xmpp_address = True not_xmpp_address = True
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment']: list[dict] = []
# remove any existing value # remove any existing value
property_found = None property_found = None

View File

@ -64,7 +64,7 @@ def set_youtube(actor_json: {}, youtube: str) -> None:
"""Sets youtube for the given actor """Sets youtube for the given actor
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
actor_json['attachment'] = [] actor_json['attachment']: list[dict] = []
# remove any existing value # remove any existing value
property_found = None property_found = None