Ensure that function arguments with default values have a type

main
Bob Mottram 2025-05-09 11:46:33 +01:00
parent 9bf73d1cf4
commit 1f97984340
7 changed files with 21 additions and 12 deletions

View File

@ -401,7 +401,7 @@ def clear_followers(base_dir: str, nickname: str, domain: str) -> None:
def _get_no_of_follows(base_dir: str, nickname: str, domain: str,
follow_file='following.txt') -> int:
follow_file: str = 'following.txt') -> int:
"""Returns the number of follows or followers
"""
# only show number of followers to authenticated
@ -444,8 +444,8 @@ def get_no_of_followers(base_dir: str, nickname: str, domain: str) -> int:
def get_following_feed(base_dir: str, domain: str, port: int, path: str,
http_prefix: str, authorized: bool,
follows_per_page=12,
follow_file='following') -> {}:
follows_per_page: int = 12,
follow_file: str = 'following') -> {}:
"""Returns the following and followers feeds from GET requests.
This accesses the following.txt or followers.txt and builds a collection.
"""

View File

@ -696,7 +696,7 @@ def clear_person_qrcodes(base_dir: str) -> None:
def save_person_qrcode(base_dir: str,
nickname: str, domain: str, qrcode_domain: str,
port: int, scale=6) -> None:
port: int, scale: int = 6) -> None:
"""Saves a qrcode image for the handle of the person
This helps to transfer onion or i2p handles to a mobile device
"""

View File

@ -200,7 +200,8 @@ def is_moderator(base_dir: str, nickname: str) -> bool:
def no_of_followers_on_domain(base_dir: str, handle: str,
domain: str, follow_file='followers.txt') -> int:
domain: str,
follow_file: str = 'followers.txt') -> int:
"""Returns the number of followers of the given handle from the
given domain
"""
@ -5679,7 +5680,7 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
base_dir: str,
boxname: str, archive_dir: str,
recent_posts_cache: {},
max_posts_in_box=32000) -> None:
max_posts_in_box: int = 32000) -> None:
"""Retain a maximum number of posts within the given box
Move any others to an archive directory
"""

View File

@ -5673,11 +5673,19 @@ def _check_self_variables(mod_name: str, method_name: str,
def _check_method_args(mod_name: str, method_name: str,
method_args: []) -> bool:
"""Tests that method arguments are not CamelCase
and that arguments with default values have types
"""
exclude_modules = ['pyjsonld']
for arg_str in method_args:
if ':' in arg_str:
arg_str = arg_str.split(':')[0]
if '=' in arg_str:
# is a type given?
if mod_name not in exclude_modules and \
':' not in arg_str and '=None' not in arg_str:
print(mod_name + ', ' + method_name + ', ' + arg_str +
', = in function argument without type')
return False
arg_str = arg_str.split('=')[0]
arg_str = arg_str.strip()
if arg_str != arg_str.lower():

View File

@ -1102,7 +1102,7 @@ def get_config_param(base_dir: str, variable_name: str) -> str:
def get_followers_list(base_dir: str,
nickname: str, domain: str,
follow_file='following.txt') -> []:
follow_file: str = 'following.txt') -> []:
"""Returns a list of followers for the given account
"""
filename = acct_dir(base_dir, nickname, domain) + '/' + follow_file
@ -1126,7 +1126,7 @@ def get_followers_list(base_dir: str,
def get_followers_of_person(base_dir: str,
nickname: str, domain: str,
follow_file='following.txt') -> []:
follow_file: str = 'following.txt') -> []:
"""Returns a list containing the followers of the given person
Used by the shared inbox to know who to send incoming mail to
"""
@ -3135,7 +3135,7 @@ def _actor_in_searchable_by(searchable_by: str, following_list: []) -> bool:
def search_box_posts(base_dir: str, nickname: str, domain: str,
search_str: str, max_results: int,
box_name='outbox') -> []:
box_name: str = 'outbox') -> []:
"""Search your posts and return a list of the filenames
containing matching strings
"""

View File

@ -723,7 +723,7 @@ def get_right_image_file(base_dir: str,
def html_header_with_external_style(css_filename: str, instance_title: str,
metadata: str, preload_images: [],
lang='en') -> str:
lang: str = 'en') -> str:
if metadata is None:
metadata = ''
css_file = '/' + css_filename.split('/')[-1]
@ -768,7 +768,7 @@ def html_header_with_external_style(css_filename: str, instance_title: str,
def html_header_with_person_markup(css_filename: str, instance_title: str,
actor_json: {}, city: str,
content_license_url: str,
lang='en') -> str:
lang: str = 'en') -> str:
"""html header which includes person markup
https://schema.org/Person
"""

View File

@ -48,7 +48,7 @@ def welcome_screen_is_complete(base_dir: str,
def html_welcome_screen(base_dir: str, nickname: str,
language: str, translate: {},
theme_name: str,
curr_screen='welcome') -> str:
curr_screen: str = 'welcome') -> str:
"""Returns the welcome screen
"""
# set a custom background for the welcome screen