From e0b866c63123897b4d963ef91e8f4c769dba797f Mon Sep 17 00:00:00 2001 From: bashrc Date: Tue, 5 May 2026 15:07:45 +0100 Subject: [PATCH] Variable types --- blocking.py | 13 +++++++------ content.py | 2 +- pyjsonld.py | 2 +- searchable.py | 4 ++-- utils.py | 8 ++++---- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/blocking.py b/blocking.py index 99564c96d..2de334083 100644 --- a/blocking.py +++ b/blocking.py @@ -602,15 +602,16 @@ def update_blocked_cache(base_dir: str, if blocked_cache_last_updated > curr_time: print('WARN: Cache updated in the future') blocked_cache_last_updated: int = 0 - seconds_since_last_update = curr_time - blocked_cache_last_updated + seconds_since_last_update: int = curr_time - blocked_cache_last_updated if seconds_since_last_update < blocked_cache_update_secs: return blocked_cache_last_updated - global_blocking_filename = data_dir(base_dir) + '/blocking.txt' + global_blocking_filename: str = data_dir(base_dir) + '/blocking.txt' if not is_a_file(global_blocking_filename): return blocked_cache_last_updated - blocked_lines = load_list(global_blocking_filename, - 'EX: update_blocked_cache unable to read ' + - global_blocking_filename + ' [ex]') + blocked_lines: list[str] = \ + load_list(global_blocking_filename, + 'EX: update_blocked_cache unable to read ' + + global_blocking_filename + ' [ex]') if blocked_lines is None: return blocked_cache_last_updated # remove newlines @@ -627,7 +628,7 @@ def _get_short_domain(domain: str) -> str: who constantly change their subdomain e.g. subdomain123.mydomain.com becomes mydomain.com """ - sections = domain.split('.') + sections: list[str] = domain.split('.') no_of_sections = len(sections) if no_of_sections > 2: return sections[no_of_sections-2] + '.' + sections[-1] diff --git a/content.py b/content.py index 340c9cb47..ca46d169d 100644 --- a/content.py +++ b/content.py @@ -1472,7 +1472,7 @@ def add_html_tags(base_dir: str, http_prefix: str, content = content.replace('#' + now_playing_lower_str, '#' + now_playing_str) content = _add_music_tag(content, now_playing_str) - words = _get_simplified_content(content).split(' ') + words: list[str] = _get_simplified_content(content).split(' ') # remove . for words which are not mentions new_words: list[str] = [] diff --git a/pyjsonld.py b/pyjsonld.py index e94239f79..ea1595a0c 100644 --- a/pyjsonld.py +++ b/pyjsonld.py @@ -2257,7 +2257,7 @@ class JsonLdProcessor(object): # continue to hash bnode quads while bnodes are assigned names unnamed = None next_unnamed = bnodes.keys() - duplicates = None + duplicates: dict = None while True: unnamed = next_unnamed next_unnamed = [] diff --git a/searchable.py b/searchable.py index ba4aadcc1..6e0f328a8 100644 --- a/searchable.py +++ b/searchable.py @@ -102,7 +102,7 @@ def _search_virtual_box_posts(base_dir: str, nickname: str, domain: str, search_str = search_str.lower().strip() if '+' in search_str: - search_words = search_str.split('+') + search_words: list[str] = search_str.split('+') for index, _ in enumerate(search_words): search_words[index] = search_words[index].strip() print('SEARCH: ' + str(search_words)) @@ -160,7 +160,7 @@ def search_box_posts(base_dir: str, nickname: str, domain: str, search_str = search_str.lower().strip() if '+' in search_str: - search_words = search_str.split('+') + search_words: list[str] = search_str.split('+') for index, _ in enumerate(search_words): search_words[index] = search_words[index].strip() print('SEARCH: ' + str(search_words)) diff --git a/utils.py b/utils.py index 617865aa0..a58e850ee 100644 --- a/utils.py +++ b/utils.py @@ -384,7 +384,7 @@ def get_media_descriptions_from_post(post_json_object: {}) -> str: """Returns all attached media descriptions as a single text. This is used for filtering """ - post_attachments = get_post_attachments(post_json_object) + post_attachments: list[dict] = get_post_attachments(post_json_object) if not post_attachments: return '' descriptions: str = '' @@ -707,10 +707,10 @@ def get_memorials(base_dir: str) -> str: if not is_a_file(memorial_file): return '' - memorial_str = load_string(memorial_file, - 'EX: unable to read ' + memorial_file) + memorial_str: str = \ + load_string(memorial_file, 'EX: unable to read ' + memorial_file) if memorial_str is None: - memorial_str: str = '' + memorial_str = '' return memorial_str