From a400bcf21f101bc9c60d9c99ed0bf82c8e5881ee Mon Sep 17 00:00:00 2001 From: bashrc Date: Mon, 27 Apr 2026 21:40:38 +0100 Subject: [PATCH] Variable types --- webapp_search.py | 10 ++--- webapp_specification.py | 2 +- webapp_suspended.py | 2 +- webapp_theme_designer.py | 6 +-- webapp_timeline.py | 50 +++++++++++----------- webapp_tos.py | 2 +- webapp_utils.py | 90 ++++++++++++++++++++-------------------- 7 files changed, 81 insertions(+), 81 deletions(-) diff --git a/webapp_search.py b/webapp_search.py index ad8f2330e..5a7d19b4f 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -222,7 +222,7 @@ def _html_shares_result(base_dir: str, shares_json: {}, page_number: int, shares_file_type: str) -> (bool, int, int, str): """Result for shared items search """ - shared_items_form = '' + shared_items_form: str = '' if curr_page > page_number: return results_exist, curr_page, ctr, shared_items_form @@ -276,7 +276,7 @@ def html_search_shared_items(translate: {}, """ curr_page = 1 ctr = 0 - shared_items_form = '' + shared_items_form: str = '' search_str_lower = urllib.parse.unquote(search_str) search_str_lower = search_str_lower.lower().strip('\n').strip('\r') search_str_lower_list = search_str_lower.split('+') @@ -491,7 +491,7 @@ def html_search(translate: {}, base_dir: str, path: str, domain: str, text_mode_banner_str = html_keyboard_navigation(text_mode_banner, {}, {}, None, None, None, False) if text_mode_banner_str is None: - text_mode_banner_str = '' + text_mode_banner_str: str = '' if os.path.isfile(search_banner_filename): timeline_key = access_keys['menuTimeline'] @@ -525,7 +525,7 @@ def html_search(translate: {}, base_dir: str, path: str, domain: str, cached_hashtag_swarm_filename = \ acct_dir(base_dir, search_nickname, domain) + '/.hashtagSwarm' - swarm_str = '' + swarm_str: str = '' if os.path.isfile(cached_hashtag_swarm_filename): swarm_str = \ load_string(cached_hashtag_swarm_filename, @@ -533,7 +533,7 @@ def html_search(translate: {}, base_dir: str, path: str, domain: str, 'html_search unable to read cached hashtag swarm ' + cached_hashtag_swarm_filename) if swarm_str is None: - swarm_str = '' + swarm_str: str = '' if not swarm_str: swarm_str = html_hash_tag_swarm(base_dir, actor, translate) if swarm_str: diff --git a/webapp_specification.py b/webapp_specification.py index 30ec45f81..639aab996 100644 --- a/webapp_specification.py +++ b/webapp_specification.py @@ -43,7 +43,7 @@ def html_specification(base_dir: str, http_prefix: str, md_text = markdown_example_numbers(md_text) specification_text = markdown_to_html(md_text) - specification_form = '' + specification_form: str = '' css_filename = base_dir + '/epicyon-profile.css' if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' diff --git a/webapp_suspended.py b/webapp_suspended.py index 81f825ae0..1a193e283 100644 --- a/webapp_suspended.py +++ b/webapp_suspended.py @@ -16,7 +16,7 @@ from webapp_utils import html_footer def html_suspended(base_dir: str) -> str: """Show the screen for suspended accounts """ - suspended_form = '' + suspended_form: str = '' css_filename = base_dir + '/epicyon-suspended.css' if os.path.isfile(base_dir + '/suspended.css'): css_filename = base_dir + '/suspended.css' diff --git a/webapp_theme_designer.py b/webapp_theme_designer.py index ee1ab87ce..541f44bf4 100644 --- a/webapp_theme_designer.py +++ b/webapp_theme_designer.py @@ -186,7 +186,7 @@ def html_theme_designer(base_dir: str, for variable_name, value in custom_theme_params.items(): theme_json[variable_name] = value - theme_form = '' + theme_form: str = '' css_filename = base_dir + '/epicyon-profile.css' if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' @@ -228,7 +228,7 @@ def html_theme_designer(base_dir: str, 'name="submitThemeDesigner" accesskey="' + submit_key + '">' + \ translate['Save'] + '\n \n' - contrast_warning = '' + contrast_warning: str = '' if theme_json.get('main-bg-color'): background = theme_json['main-bg-color'] if theme_json.get('main-fg-color'): @@ -320,7 +320,7 @@ def html_theme_designer(base_dir: str, switch_str += \ ' ' - checked_str = '' + checked_str: str = '' if value.title() == 'True': checked_str = ' checked' switch_str += \ diff --git a/webapp_timeline.py b/webapp_timeline.py index 32a98d4c3..00f0834c3 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -121,7 +121,7 @@ def _html_timeline_new_post(manually_approve_followers: bool, access_keys: {}) -> str: """Returns html for the new post button """ - new_post_button_str = '' + new_post_button_str: str = '' if box_name == 'dm': new_post_button_str += \ '────' num_str += html_hide_from_screen_reader(separator_str) - aria_page_str = '' + aria_page_str: str = '' page_str = ' ' + str(page) + ' ' - curr_page_str = '' + curr_page_str: str = '' if page == page_number: page_str = '[' + str(page) + ']' aria_page_str = ' aria-current="true"' @@ -574,7 +574,7 @@ def html_timeline(default_timeline: str, if os.path.isfile(show_vote_file): show_vote_posts = False - separator_str = '' + separator_str: str = '' if box_name != 'tlmedia': separator_str = html_post_separator(base_dir, None) @@ -660,7 +660,7 @@ def html_timeline(default_timeline: str, show_individual_post_icons = True # show an icon for new follow approvals - follow_approvals = '' + follow_approvals: str = '' follow_requests_filename = \ acct_dir(base_dir, nickname, domain) + '/followrequests.txt' if os.path.isfile(follow_requests_filename): @@ -690,7 +690,7 @@ def html_timeline(default_timeline: str, _log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '3') # moderation / reports button - moderation_button_str = '' + moderation_button_str: str = '' if moderator and not minimal: moderation_button_str = \ '' # shares, bookmarks and events buttons - shares_button_str = '' - wanted_button_str = '' - bookmarks_button_str = '' - events_button_str = '' + shares_button_str: str = '' + wanted_button_str: str = '' + bookmarks_button_str: str = '' + events_button_str: str = '' if not minimal: shares_button_str = \ '
' else: - text_mode_separator = '' + text_mode_separator: str = '' # page up arrow if page_number > 1 or is_text_browser: @@ -980,7 +980,7 @@ def html_timeline(default_timeline: str, tl_str += '
' + \ page_number_buttons(users_path, box_name, page_number, 'timelineposts') - first_post_str = '' + first_post_str: str = '' if page_number > 2: if last_post_id: first_post_str = ';firstpost=' + last_post_id @@ -1009,10 +1009,10 @@ def html_timeline(default_timeline: str, if box_name == 'inbox': use_cache_only = True - first_post_id = '' - last_post_id = '' + first_post_id: str = '' + last_post_id: str = '' - last_item_str = '' + last_item_str: str = '' if timeline_json: # if this is the media timeline then add an extra gallery container if box_name == 'tlmedia': @@ -1033,7 +1033,7 @@ def html_timeline(default_timeline: str, mutuals_list = get_mutuals_of_person(base_dir, nickname, domain) # show each post in the timeline - tl_items_str = '' + tl_items_str: str = '' for item in timeline_json['orderedItems']: if item['type'] in ('Create', 'Announce'): # is the actor who sent this post snoozed? @@ -1162,10 +1162,10 @@ def html_timeline(default_timeline: str, if item_ctr > items_per_page / 2: tl_str = tl_str.replace(last_item_str, '') tl_str += text_mode_separator - first_post = '' + first_post: str = '' if last_post_id: first_post = ';firstpost=' + last_post_id.replace('#', '--') - last_post = '' + last_post: str = '' if first_post_id: last_post = ';lastpost=' + first_post_id.replace('#', '--') tl_str += \ @@ -1303,11 +1303,11 @@ def _html_shares_timeline(translate: {}, page_number: int, items_per_page: int, domain_full = get_full_domain(domain, port) actor = local_actor_url(http_prefix, nickname, domain_full) admin_nickname = get_config_param(base_dir, 'admin') - admin_actor = '' + admin_actor: str = '' if admin_nickname: admin_actor = \ local_actor_url(http_prefix, admin_nickname, domain_full) - timeline_str = '' + timeline_str: str = '' if page_number > 1: timeline_str += '
' + \ diff --git a/webapp_tos.py b/webapp_tos.py index 035097acb..fb531a41b 100644 --- a/webapp_tos.py +++ b/webapp_tos.py @@ -42,7 +42,7 @@ def html_terms_of_service(base_dir: str, if tos_text_str: tos_text = markdown_to_html(tos_text_str) - tos_form = '' + tos_form: str = '' css_filename = base_dir + '/epicyon-profile.css' if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' diff --git a/webapp_utils.py b/webapp_utils.py index f77ae0492..3638a742b 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -138,7 +138,7 @@ def csv_following_list(following_filename: str, following_list = msg.split('\n') following_list.sort() if following_list: - following_list_csv = '' + following_list_csv: str = '' for following_address in following_list: if not following_address: continue @@ -153,7 +153,7 @@ def csv_following_list(following_filename: str, following_nickname, following_domain) notify_on_new = 'false' - languages = '' + languages: str = '' person_notes = \ get_person_notes(base_dir, nickname, domain, following_address) @@ -184,7 +184,7 @@ def csv_following_list(following_filename: str, def html_hashtag_blocked(base_dir: str, translate: {}) -> str: """Show the screen for a blocked hashtag """ - blocked_hashtag_form = '' + blocked_hashtag_form: str = '' css_filename = base_dir + '/epicyon-suspended.css' if os.path.isfile(base_dir + '/suspended.css'): css_filename = base_dir + '/suspended.css' @@ -212,7 +212,7 @@ def header_buttons_front_screen(translate: {}, authorized: bool) -> str: """Returns the header buttons for the front page of a news instance """ - header_str = '' + header_str: str = '' if nickname == 'news': button_features = 'buttonMobile' if box_name == 'features': @@ -729,11 +729,11 @@ def html_header_with_external_style(css_filename: str, instance_title: str, metadata: str, preload_images: [], lang: str = 'en') -> str: if metadata is None: - metadata = '' + metadata: str = '' css_file = '/' + css_filename.split('/')[-1] pwa_theme_color, pwa_theme_background_color = \ get_pwa_theme_colors(css_filename) - preload_images_str = '' + preload_images_str: str = '' if preload_images: for image_path in preload_images: preload_images_str += \ @@ -784,11 +784,11 @@ def html_header_with_person_markup(css_filename: str, instance_title: str, preload_images, lang) return html_str - city_markup = '' + city_markup: str = '' if city: city = city.lower().title() - add_comma = '' - country_markup = '' + add_comma: str = '' + country_markup: str = '' if ',' in city: country = city.split(',', 1)[1].strip().title() city = city.split(',', 1)[0] @@ -801,7 +801,7 @@ def html_header_with_person_markup(css_filename: str, instance_title: str, ' "addressLocality": "' + city + '"' + \ add_comma + '\n' + country_markup + ' },\n' - skills_markup = '' + skills_markup: str = '' if actor_json.get('hasOccupation'): if isinstance(actor_json['hasOccupation'], list): skills_markup = ' "hasOccupation": [\n' @@ -872,7 +872,7 @@ def html_header_with_person_markup(css_filename: str, instance_title: str, first_entry = False skills_markup += '\n ],\n' - description = '' + description: str = '' if actor_json.get('summary'): description = remove_html(actor_json['summary']) name_str = remove_html(actor_json['name']) @@ -1103,7 +1103,7 @@ def load_individual_post_as_html_from_cache(base_dir: str, cached_post_filename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) - post_html = '' + post_html: str = '' if not cached_post_filename: return post_html @@ -1278,9 +1278,9 @@ def get_post_attachments_as_html(base_dir: str, system_language: str) -> (str, str): """Returns a string representing any attachments """ - attachment_str = '' - attachment_ctr = 0 - gallery_str = '' + attachment_str: str = '' + attachment_ctr: int = 0 + gallery_str: str = '' attachment_dict: list[dict] = [] # handle peertube-style video posts, where the media links @@ -1342,7 +1342,7 @@ def get_post_attachments_as_html(base_dir: str, '.' not in url: continue # get the domain for the chat link - chat_domain_str = '' + chat_domain_str: str = '' attach_url = remove_html(url) if attach_url in attached_urls: continue @@ -1355,7 +1355,7 @@ def get_post_attachments_as_html(base_dir: str, chat_domain_str = ' (' + chat_domain + ')' # avoid displaying very long domains if len(chat_domain_str) > 50: - chat_domain_str = '' + chat_domain_str: str = '' chat_url = remove_html(url) attachment_str += \ '

\n' gallery_str += ' \n' - license_str = '' + license_str: str = '' if media_license and media_creator: media_license = remove_html(media_license) if resembles_url(media_license): @@ -1544,7 +1544,7 @@ def get_post_attachments_as_html(base_dir: str, # don't show the announce icon if there is no image # description if not image_description: - announce_str = '' + announce_str: str = '' gallery_str += \ ' ' + reply_str + announce_str + like_str + \ bookmark_str + delete_str + mute_str + '\n' @@ -1600,7 +1600,7 @@ def get_post_attachments_as_html(base_dir: str, '" alt="' + image_description + '" title="' + \ image_description + '" class="attachment">\n' if media_license and media_creator: - license_str = '' + license_str: str = '' attachment_str += '

' media_license = remove_html(media_license) if resembles_url(media_license): @@ -1793,7 +1793,7 @@ def html_post_separator(base_dir: str, column: str) -> str: filename = 'separator_' + column + '.png' separator_image_filename = \ base_dir + '/theme/' + theme + '/icons/' + filename - separator_str = '' + separator_str: str = '' if os.path.isfile(separator_image_filename): separator_str = \ '
' + \ @@ -1873,7 +1873,7 @@ def html_keyboard_navigation(banner: str, links: {}, access_keys: {}, # show the list of links for title, url in links.items(): - access_key_str = '' + access_key_str: str = '' if access_keys.get(title): access_key_str = 'accesskey="' + access_keys[title] + '"' @@ -1904,14 +1904,14 @@ def edit_text_field(label: str, name: str, value: str = "", """Returns html for editing a text field """ if value is None: - value = '' - placeholder_str = '' + value: str = '' + placeholder_str: str = '' if placeholder: placeholder_str = ' placeholder="' + placeholder + '"' - required_str = '' + required_str: str = '' if required: required_str = ' required' - text_field_str = '' + text_field_str: str = '' if label: text_field_str = \ '
\n' @@ -1927,8 +1927,8 @@ def edit_number_field(label: str, name: str, value: int, """Returns html for editing an integer number field """ if value is None: - value = '' - placeholder_str = '' + value: str = '' + placeholder_str: str = '' if placeholder: placeholder_str = ' placeholder="' + str(placeholder) + '"' return \ @@ -1944,11 +1944,11 @@ def edit_currency_field(label: str, name: str, value: str, """ if value is None: value = '0.00' - placeholder_str = '' + placeholder_str: str = '' if placeholder: if placeholder.isdigit(): placeholder_str = ' placeholder="' + str(placeholder) + '"' - required_str = '' + required_str: str = '' if required: required_str = ' required' return \ @@ -1962,7 +1962,7 @@ def edit_currency_field(label: str, name: str, value: str, def edit_check_box(label: str, name: str, checked: bool) -> str: """Returns html for editing a checkbox field """ - checked_str = '' + checked_str: str = '' if checked: checked_str = ' checked' @@ -1976,8 +1976,8 @@ def edit_text_area(label: str, subtitle: str, name: str, value: str, """Returns html for editing a textarea field """ if value is None: - value = '' - text = '' + value: str = '' + text: str = '' if label: text = '
\n' if subtitle: @@ -2215,7 +2215,7 @@ def html_common_emoji(base_dir: str, no_of_emoji: int) -> str: return '' line_ctr = 0 ctr = 0 - html_str = '' + html_str: str = '' while ctr < no_of_emoji and line_ctr < len(common_emoji): name_initial = common_emoji[line_ctr].split(' ') if len(name_initial) < 2: @@ -2278,7 +2278,7 @@ def html_following_data_list(base_dir: str, nickname: str, list_str = '\n' following_filename = \ acct_dir(base_dir, nickname, domain) + '/' + following_type + '.txt' - msg = '' + msg: str = '' if os.path.isfile(following_filename): msg = load_string(following_filename, 'EX: html_following_data_list unable to read ' + @@ -2288,7 +2288,7 @@ def html_following_data_list(base_dir: str, nickname: str, # to yourself as reminders msg += nickname + '@' + domain_full + '\n' else: - msg = '' + msg: str = '' if msg: # include petnames petnames_filename = \ @@ -2331,7 +2331,7 @@ def html_following_dropdown(base_dir: str, nickname: str, list_str = '