Avoid default arguments, which make static analysis harder

main
Bob Mottram 2021-10-29 23:26:45 +01:00
parent 5913bf3466
commit 24ac3184b4
8 changed files with 37 additions and 40 deletions

View File

@ -203,7 +203,7 @@ def authorize(baseDir: str, path: str, authHeader: str, debug: bool) -> bool:
return False
def createPassword(length: int = 10):
def createPassword(length: int):
validChars = 'abcdefghijklmnopqrstuvwxyz' + \
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
return ''.join((secrets.choice(validChars) for i in range(length)))

View File

@ -954,9 +954,9 @@ def _desktopShowBox(indent: str,
yourActor: str, boxName: str, boxJson: {},
translate: {},
screenreader: str, systemLanguage: str, espeak,
pageNumber: int = 1,
newReplies: bool = False,
newDMs: bool = False) -> bool:
pageNumber: int,
newReplies: bool,
newDMs: bool) -> bool:
"""Shows online timeline
"""
numberWidth = 2

View File

@ -2101,7 +2101,7 @@ if args.followers:
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if not personUrl:
personUrl = getUserUrl(wfRequest)
personUrl = getUserUrl(wfRequest, 0, args.debug)
if nickname == domain:
personUrl = personUrl.replace('/users/', '/actor/')
personUrl = personUrl.replace('/accounts/', '/actor/')

View File

@ -20,7 +20,7 @@ from utils import hasObjectDict
from utils import acctDir
def _validUuid(testUuid: str, version: int = 4):
def _validUuid(testUuid: str, version: int):
"""Check if uuid_to_test is a valid UUID
"""
try:
@ -77,7 +77,7 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
if eventJson.get('name') and eventJson.get('actor') and \
eventJson.get('uuid') and eventJson.get('content'):
if not _validUuid(eventJson['uuid']):
if not _validUuid(eventJson['uuid'], 4):
return False
print('Mobilizon type event')
# if this is a full description of an event then save it
@ -166,8 +166,8 @@ def _isHappeningPost(postJsonObject: {}) -> bool:
def getTodaysEvents(baseDir: str, nickname: str, domain: str,
currYear: int = None, currMonthNumber: int = None,
currDayOfMonth: int = None) -> {}:
currYear: int, currMonthNumber: int,
currDayOfMonth: int) -> {}:
"""Retrieves calendar events for today
Returns a dictionary of lists containing Event and Place activities
"""

View File

@ -365,8 +365,7 @@ def attachMedia(baseDir: str, httpPrefix: str,
return postJson
def archiveMedia(baseDir: str, archiveDirectory: str,
maxWeeks: int = 4) -> None:
def archiveMedia(baseDir: str, archiveDirectory: str, maxWeeks: int) -> None:
"""Any media older than the given number of weeks gets archived
"""
if maxWeeks == 0:

View File

@ -132,8 +132,8 @@ def _addNewswireDictEntry(baseDir: str, domain: str,
votesStatus: str, postFilename: str,
description: str, moderated: bool,
mirrored: bool,
tags: [] = [],
maxTags: int = 32) -> None:
tags: [],
maxTags: int) -> None:
"""Update the newswire dictionary
"""
# remove any markup
@ -378,7 +378,7 @@ def _xml2StrToDict(baseDir: str, domain: str, xmlStr: str,
title, link,
votesStatus, postFilename,
description, moderated,
mirrored)
mirrored, [], 32)
postCtr += 1
if postCtr >= maxPostsPerSource:
break
@ -465,7 +465,7 @@ def _xml1StrToDict(baseDir: str, domain: str, xmlStr: str,
title, link,
votesStatus, postFilename,
description, moderated,
mirrored)
mirrored, [], 32)
postCtr += 1
if postCtr >= maxPostsPerSource:
break
@ -540,7 +540,7 @@ def _atomFeedToDict(baseDir: str, domain: str, xmlStr: str,
title, link,
votesStatus, postFilename,
description, moderated,
mirrored)
mirrored, [], 32)
postCtr += 1
if postCtr >= maxPostsPerSource:
break
@ -651,7 +651,7 @@ def _jsonFeedV1ToDict(baseDir: str, domain: str, xmlStr: str,
title, link,
votesStatus, postFilename,
description, moderated,
mirrored)
mirrored, [], 32)
postCtr += 1
if postCtr >= maxPostsPerSource:
break
@ -722,7 +722,8 @@ def _atomFeedYTToDict(baseDir: str, domain: str, xmlStr: str,
result, pubDateStr,
title, link,
votesStatus, postFilename,
description, moderated, mirrored)
description, moderated, mirrored,
[], 32)
postCtr += 1
if postCtr >= maxPostsPerSource:
break

View File

@ -196,7 +196,7 @@ def _cleanHtml(rawHtml: str) -> str:
return html.unescape(text)
def getUserUrl(wfRequest: {}, sourceId: int = 0, debug: bool = False) -> str:
def getUserUrl(wfRequest: {}, sourceId: int, debug: bool) -> str:
"""Gets the actor url from a webfinger request
"""
if not wfRequest.get('links'):
@ -3197,7 +3197,7 @@ def sendToFollowersThread(session, baseDir: str,
def createInbox(recentPostsCache: {},
session, baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
pageNumber: int = None) -> {}:
pageNumber: int) -> {}:
return _createBoxIndexed(recentPostsCache,
session, baseDir, 'inbox',
nickname, domain, port, httpPrefix,
@ -3207,7 +3207,7 @@ def createInbox(recentPostsCache: {},
def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber: int = None) -> {}:
headerOnly: bool, pageNumber: int) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlbookmarks',
nickname, domain,
port, httpPrefix, itemsPerPage, headerOnly,
@ -3217,7 +3217,7 @@ def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str,
def createDMTimeline(recentPostsCache: {},
session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber: int = None) -> {}:
headerOnly: bool, pageNumber: int) -> {}:
return _createBoxIndexed(recentPostsCache,
session, baseDir, 'dm', nickname,
domain, port, httpPrefix, itemsPerPage,
@ -3227,7 +3227,7 @@ def createDMTimeline(recentPostsCache: {},
def createRepliesTimeline(recentPostsCache: {},
session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber: int = None) -> {}:
headerOnly: bool, pageNumber: int) -> {}:
return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies',
nickname, domain, port, httpPrefix,
itemsPerPage, headerOnly, True,
@ -3236,7 +3236,7 @@ def createRepliesTimeline(recentPostsCache: {},
def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber: int = None) -> {}:
headerOnly: bool, pageNumber: int) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlblogs', nickname,
domain, port, httpPrefix,
itemsPerPage, headerOnly, True,
@ -3245,7 +3245,7 @@ def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str,
def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber: int = None) -> {}:
headerOnly: bool, pageNumber: int) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlfeatures', nickname,
domain, port, httpPrefix,
itemsPerPage, headerOnly, True,
@ -3254,7 +3254,7 @@ def createFeaturesTimeline(session, baseDir: str, nickname: str, domain: str,
def createMediaTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, pageNumber: int = None) -> {}:
headerOnly: bool, pageNumber: int) -> {}:
return _createBoxIndexed({}, session, baseDir, 'tlmedia', nickname,
domain, port, httpPrefix,
itemsPerPage, headerOnly, True,
@ -3265,7 +3265,7 @@ def createNewsTimeline(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str, itemsPerPage: int,
headerOnly: bool, newswireVotesThreshold: int,
positiveVoting: bool, votingTimeMins: int,
pageNumber: int = None) -> {}:
pageNumber: int) -> {}:
return _createBoxIndexed({}, session, baseDir, 'outbox', 'news',
domain, port, httpPrefix,
itemsPerPage, headerOnly, True,
@ -3276,7 +3276,7 @@ def createNewsTimeline(session, baseDir: str, nickname: str, domain: str,
def createOutbox(session, baseDir: str, nickname: str, domain: str,
port: int, httpPrefix: str,
itemsPerPage: int, headerOnly: bool, authorized: bool,
pageNumber: int = None) -> {}:
pageNumber: int) -> {}:
return _createBoxIndexed({}, session, baseDir, 'outbox',
nickname, domain, port, httpPrefix,
itemsPerPage, headerOnly, authorized,
@ -3285,7 +3285,7 @@ def createOutbox(session, baseDir: str, nickname: str, domain: str,
def createModeration(baseDir: str, nickname: str, domain: str, port: int,
httpPrefix: str, itemsPerPage: int, headerOnly: bool,
pageNumber: int = None) -> {}:
pageNumber: int) -> {}:
boxDir = createPersonDir(nickname, domain, baseDir, 'inbox')
boxname = 'moderation'

View File

@ -1219,9 +1219,9 @@ def editTextField(label: str, name: str, value: str = "",
value + '"' + placeholderStr + requiredStr + '>\n'
def editNumberField(label: str, name: str, value: int = 1,
minValue: int = 1, maxValue: int = 999999,
placeholder: int = 1) -> str:
def editNumberField(label: str, name: str, value: int,
minValue: int, maxValue: int,
placeholder: int) -> str:
"""Returns html for editing an integer number field
"""
if value is None:
@ -1236,9 +1236,8 @@ def editNumberField(label: str, name: str, value: int = 1,
'min="' + str(minValue) + '" max="' + str(maxValue) + '" step="1">\n'
def editCurrencyField(label: str, name: str, value: str = "0.00",
placeholder: str = "0.00",
required: bool = False) -> str:
def editCurrencyField(label: str, name: str, value: str,
placeholder: str, required: bool) -> str:
"""Returns html for editing a currency field
"""
if value is None:
@ -1258,7 +1257,7 @@ def editCurrencyField(label: str, name: str, value: str = "0.00",
requiredStr + '>\n'
def editCheckBox(label: str, name: str, checked: bool = False) -> str:
def editCheckBox(label: str, name: str, checked: bool) -> str:
"""Returns html for editing a checkbox field
"""
checkedStr = ''
@ -1270,10 +1269,8 @@ def editCheckBox(label: str, name: str, checked: bool = False) -> str:
'name="' + name + '"' + checkedStr + '> ' + label + '<br>\n'
def editTextArea(label: str, name: str, value: str = "",
height: int = 600,
placeholder: str = "",
spellcheck: bool = False) -> str:
def editTextArea(label: str, name: str, value: str,
height: int, placeholder: str, spellcheck: bool) -> str:
"""Returns html for editing a textarea field
"""
if value is None: