diff --git a/categories.py b/categories.py index 40a31c51f..70d079a78 100644 --- a/categories.py +++ b/categories.py @@ -30,7 +30,8 @@ def getHashtagCategory(baseDir: str, hashtag: str) -> str: return '' -def getHashtagCategories(baseDir: str, recent=False, category=None) -> None: +def getHashtagCategories(baseDir: str, + recent: bool = False, category: str = None) -> None: """Returns a dictionary containing hashtag categories """ maxTagLength = 42 @@ -128,7 +129,7 @@ def _validHashtagCategory(category: str) -> bool: def setHashtagCategory(baseDir: str, hashtag: str, category: str, - force=False) -> bool: + force: bool = False) -> bool: """Sets the category for the hashtag """ if not _validHashtagCategory(category): diff --git a/content.py b/content.py index 8412964ab..22ba06f0b 100644 --- a/content.py +++ b/content.py @@ -736,7 +736,8 @@ def _autoTag(baseDir: str, nickname: str, domain: str, def addHtmlTags(baseDir: str, httpPrefix: str, nickname: str, domain: str, content: str, - recipients: [], hashtags: {}, isJsonContent=False) -> str: + recipients: [], hashtags: {}, + isJsonContent: bool = False) -> str: """ Replaces plaintext mentions such as @nick@domain into html by matching against known following accounts """ @@ -923,7 +924,7 @@ def extractMediaInFormPOST(postBytes, boundary, name: str): def saveMediaInFormPOST(mediaBytes, debug: bool, - filenameBase=None) -> (str, str): + filenameBase: str = None) -> (str, str): """Saves the given media bytes extracted from http form POST Returns the filename and attachment type """ @@ -1007,8 +1008,8 @@ def saveMediaInFormPOST(mediaBytes, debug: bool, return filename, attachmentMediaType -def extractTextFieldsInPOST(postBytes, boundary, debug: bool, - unitTestData=None) -> {}: +def extractTextFieldsInPOST(postBytes, boundary: str, debug: bool, + unitTestData: str = None) -> {}: """Returns a dictionary containing the text fields of a http form POST The boundary argument comes from the http header """ diff --git a/daemon.py b/daemon.py index bec263466..c9bc684b5 100644 --- a/daemon.py +++ b/daemon.py @@ -1009,7 +1009,7 @@ class PubServer(BaseHTTPRequestHandler): return True def _postToOutbox(self, messageJson: {}, version: str, - postToNickname=None) -> bool: + postToNickname: str = None) -> bool: """post is received by the outbox Client to server message post https://www.w3.org/TR/activitypub/#client-to-server-outbox-delivery @@ -14878,14 +14878,19 @@ def runDaemon(logLoginFailures: bool, baseDir: str, domain: str, onionDomain: str, i2pDomain: str, YTReplacementDomain: str, - port=80, proxyPort=80, httpPrefix='https', - fedList=[], maxMentions=10, maxEmoji=10, - authenticatedFetch=False, - proxyType=None, maxReplies=64, - domainMaxPostsPerDay=8640, accountMaxPostsPerDay=864, - allowDeletion=False, debug=False, unitTest=False, - instanceOnlySkillsSearch=False, sendThreads=[], - manualFollowerApproval=True) -> None: + port: int = 80, proxyPort: int = 80, + httpPrefix: str = 'https', + fedList: [] = [], + maxMentions: int = 10, maxEmoji: int = 10, + authenticatedFetch: bool = False, + proxyType: str = None, maxReplies: int = 64, + domainMaxPostsPerDay: int = 8640, + accountMaxPostsPerDay: int = 864, + allowDeletion: bool = False, + debug: bool = False, unitTest: bool = False, + instanceOnlySkillsSearch: bool = False, + sendThreads: [] = [], + manualFollowerApproval: bool = True) -> None: if len(domain) == 0: domain = 'localhost' if '.' not in domain: diff --git a/desktop_client.py b/desktop_client.py index 69da9f906..ce47c52aa 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -393,8 +393,8 @@ def _textToSpeech(sayStr: str, screenreader: str, def _sayCommand(content: str, sayStr: str, screenreader: str, systemLanguage: str, espeak=None, - speakerName='screen reader', - speakerGender='They/Them') -> None: + speakerName: str = 'screen reader', + speakerGender: str = 'They/Them') -> None: """Speaks a command """ print(content) @@ -927,9 +927,9 @@ def _desktopShowBox(indent: str, yourActor: str, boxName: str, boxJson: {}, translate: {}, screenreader: str, systemLanguage: str, espeak, - pageNumber=1, - newReplies=False, - newDMs=False) -> bool: + pageNumber: int = 1, + newReplies: bool = False, + newDMs: bool = False) -> bool: """Shows online timeline """ numberWidth = 2 diff --git a/follow.py b/follow.py index acabd00fc..0b1ecbc4d 100644 --- a/follow.py +++ b/follow.py @@ -238,8 +238,8 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str, def unfollowAccount(baseDir: str, nickname: str, domain: str, followNickname: str, followDomain: str, - followFile='following.txt', - debug=False) -> bool: + followFile: str = 'following.txt', + debug: bool = False) -> bool: """Removes a person to the follow list """ if ':' in domain: @@ -287,7 +287,7 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str, def unfollowerOfAccount(baseDir: str, nickname: str, domain: str, followerNickname: str, followerDomain: str, - debug=False) -> bool: + debug: bool = False) -> bool: """Remove a follower of a person """ return unfollowAccount(baseDir, nickname, domain, diff --git a/git.py b/git.py index 86da50508..71fdc1442 100644 --- a/git.py +++ b/git.py @@ -44,7 +44,7 @@ def _getGitProjectName(baseDir: str, nickname: str, domain: str, def isGitPatch(baseDir: str, nickname: str, domain: str, messageType: str, subject: str, content: str, - checkProjectName=True) -> bool: + checkProjectName: bool = True) -> bool: """Is the given post content a git patch? """ if messageType != 'Note' and \ diff --git a/happening.py b/happening.py index 1a94873fb..f1443164a 100644 --- a/happening.py +++ b/happening.py @@ -173,8 +173,8 @@ def _isHappeningPost(postJsonObject: {}) -> bool: def getTodaysEvents(baseDir: str, nickname: str, domain: str, - currYear=None, currMonthNumber=None, - currDayOfMonth=None) -> {}: + currYear: int = None, currMonthNumber: int = None, + currDayOfMonth: int = None) -> {}: """Retrieves calendar events for today Returns a dictionary of lists containing Event and Place activities """ diff --git a/httpsig.py b/httpsig.py index 03cdc93fd..45372fc90 100644 --- a/httpsig.py +++ b/httpsig.py @@ -248,7 +248,7 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict, path: str, GETmethod: bool, messageBodyDigest: str, messageBodyJsonStr: str, debug: bool, - noRecencyCheck=False) -> bool: + noRecencyCheck: bool = False) -> bool: """Returns true or false depending on if the key that we plugged in here validates against the headers, method, and path. publicKeyPem - the public key from an rsa key pair diff --git a/newswire.py b/newswire.py index 24297bc05..51c773994 100644 --- a/newswire.py +++ b/newswire.py @@ -145,7 +145,7 @@ def _addNewswireDictEntry(baseDir: str, domain: str, ] -def _validFeedDate(pubDate: str, debug=False) -> bool: +def _validFeedDate(pubDate: str, debug: bool = False) -> bool: # convert from YY-MM-DD HH:MM:SS+00:00 to # YY-MM-DDTHH:MM:SSZ postDate = pubDate.replace(' ', 'T').replace('+00:00', 'Z') @@ -226,7 +226,7 @@ def loadHashtagCategories(baseDir: str, language: str) -> None: def _xml2StrToHashtagCategories(baseDir: str, xmlStr: str, maxCategoriesFeedItemSizeKb: int, - force=False) -> None: + force: bool = False) -> None: """Updates hashtag categories based upon an rss feed """ rssItems = xmlStr.split('') diff --git a/person.py b/person.py index 164662c4b..0771bd115 100644 --- a/person.py +++ b/person.py @@ -220,7 +220,7 @@ def getDefaultPersonContext() -> str: def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, saveToFile: bool, manualFollowerApproval: bool, - password=None) -> (str, str, {}, {}): + password: str = None) -> (str, str, {}, {}): """Returns the private key, public key, actor and webfinger endpoint """ privateKeyPem, publicKeyPem = generateRSAKey() @@ -421,7 +421,7 @@ def registerAccount(baseDir: str, httpPrefix: str, domain: str, port: int, def createGroup(baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, saveToFile: bool, - password=None) -> (str, str, {}, {}): + password: str = None) -> (str, str, {}, {}): """Returns a group """ (privateKeyPem, publicKeyPem, @@ -451,7 +451,7 @@ def savePersonQrcode(baseDir: str, def createPerson(baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, saveToFile: bool, manualFollowerApproval: bool, - password=None) -> (str, str, {}, {}): + password: str = None) -> (str, str, {}, {}): """Returns the private key, public key, actor and webfinger endpoint """ if not validNickname(domain, nickname): @@ -1210,7 +1210,7 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str, def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool, - debug: bool, quiet=False) -> ({}, {}): + debug: bool, quiet: bool = False) -> ({}, {}): """Returns the actor json """ if debug: diff --git a/pgp.py b/pgp.py index f8cb96970..b32958603 100644 --- a/pgp.py +++ b/pgp.py @@ -332,7 +332,8 @@ def _pgpEncrypt(content: str, recipientPubKey: str) -> str: return encryptResult -def _getPGPPublicKeyFromActor(domain: str, handle: str, actorJson=None) -> str: +def _getPGPPublicKeyFromActor(domain: str, handle: str, + actorJson: {} = None) -> str: """Searches tags on the actor to see if there is any PGP public key specified """ diff --git a/posts.py b/posts.py index 6c26b3d04..862705234 100644 --- a/posts.py +++ b/posts.py @@ -121,8 +121,8 @@ def noOfFollowersOnDomain(baseDir: str, handle: str, return ctr -def _getPersonKey(nickname: str, domain: str, baseDir: str, keyType='public', - debug=False): +def _getPersonKey(nickname: str, domain: str, baseDir: str, + keyType: str = 'public', debug: bool = False): """Returns the public or private key of a person """ handle = nickname + '@' + domain @@ -147,7 +147,7 @@ def _cleanHtml(rawHtml: str) -> str: return html.unescape(text) -def getUserUrl(wfRequest: {}, sourceId=0, debug=False) -> str: +def getUserUrl(wfRequest: {}, sourceId: int = 0, debug: bool = False) -> str: """Gets the actor url from a webfinger request """ if not wfRequest.get('links'): @@ -871,15 +871,18 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int, mediaType: str, imageDescription: str, city: str, isModerationReport: bool, isArticle: bool, - inReplyTo=None, - inReplyToAtomUri=None, subject=None, schedulePost=False, - eventDate=None, eventTime=None, location=None, - eventUUID=None, category=None, joinMode=None, - endDate=None, endTime=None, - maximumAttendeeCapacity=None, - repliesModerationOption=None, - anonymousParticipationEnabled=None, - eventStatus=None, ticketUrl=None) -> {}: + inReplyTo: str = None, + inReplyToAtomUri: str = None, + subject: str = None, schedulePost: bool = False, + eventDate: str = None, eventTime: str = None, + location: str = None, + eventUUID: str = None, category: str = None, + joinMode: str = None, + endDate: str = None, endTime: str = None, + maximumAttendeeCapacity: int = None, + repliesModerationOption: str = None, + anonymousParticipationEnabled: bool = None, + eventStatus: str = None, ticketUrl: str = None) -> {}: """Creates a message """ content = removeInvalidChars(content) @@ -1399,10 +1402,12 @@ def createPublicPost(baseDir: str, clientToServer: bool, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - inReplyTo=None, inReplyToAtomUri=None, subject=None, - schedulePost=False, - eventDate=None, eventTime=None, location=None, - isArticle=False) -> {}: + inReplyTo: str = None, + inReplyToAtomUri: str = None, subject: str = None, + schedulePost: bool = False, + eventDate: str = None, eventTime: str = None, + location: str = None, + isArticle: bool = False) -> {}: """Public post """ domainFull = getFullDomain(domain, port) @@ -1472,9 +1477,10 @@ def createBlogPost(baseDir: str, clientToServer: bool, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - inReplyTo=None, inReplyToAtomUri=None, subject=None, - schedulePost=False, - eventDate=None, eventTime=None, location=None) -> {}: + inReplyTo: str = None, inReplyToAtomUri: str = None, + subject: str = None, schedulePost: bool = False, + eventDate: str = None, eventTime: str = None, + location: str = None) -> {}: blogJson = \ createPublicPost(baseDir, nickname, domain, port, httpPrefix, @@ -1570,9 +1576,10 @@ def createUnlistedPost(baseDir: str, clientToServer: bool, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - inReplyTo=None, inReplyToAtomUri=None, subject=None, - schedulePost=False, - eventDate=None, eventTime=None, location=None) -> {}: + inReplyTo: str = None, inReplyToAtomUri: str = None, + subject: str = None, schedulePost: bool = False, + eventDate: str = None, eventTime: str = None, + location: str = None) -> {}: """Unlisted post. This has the #Public and followers links inverted. """ domainFull = getFullDomain(domain, port) @@ -1599,10 +1606,11 @@ def createFollowersOnlyPost(baseDir: str, clientToServer: bool, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - inReplyTo=None, inReplyToAtomUri=None, - subject=None, schedulePost=False, - eventDate=None, eventTime=None, - location=None) -> {}: + inReplyTo: str = None, + inReplyToAtomUri: str = None, + subject: str = None, schedulePost: bool = False, + eventDate: str = None, eventTime: str = None, + location: str = None) -> {}: """Followers only post """ domainFull = getFullDomain(domain, port) @@ -1629,14 +1637,15 @@ def createEventPost(baseDir: str, clientToServer: bool, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - subject=None, schedulePost=False, - eventDate=None, eventTime=None, - location=None, category=None, joinMode=None, - endDate=None, endTime=None, - maximumAttendeeCapacity=None, - repliesModerationOption=None, - anonymousParticipationEnabled=None, - eventStatus=None, ticketUrl=None) -> {}: + subject: str = None, schedulePost: str = False, + eventDate: str = None, eventTime: str = None, + location: str = None, category: str = None, + joinMode: str = None, + endDate: str = None, endTime: str = None, + maximumAttendeeCapacity: int = None, + repliesModerationOption: str = None, + anonymousParticipationEnabled: bool = None, + eventStatus: str = None, ticketUrl: str = None) -> {}: """Mobilizon-type Event post """ if not attachImageFilename: @@ -1714,11 +1723,12 @@ def createDirectMessagePost(baseDir: str, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - inReplyTo=None, inReplyToAtomUri=None, - subject=None, debug=False, - schedulePost=False, - eventDate=None, eventTime=None, - location=None) -> {}: + inReplyTo: str = None, + inReplyToAtomUri: str = None, + subject: str = None, debug: bool = False, + schedulePost: bool = False, + eventDate: str = None, eventTime: str = None, + location: str = None) -> {}: """Direct Message post """ content = resolvePetnames(baseDir, nickname, domain, content) @@ -1759,7 +1769,7 @@ def createReportPost(baseDir: str, clientToServer: bool, commentsEnabled: bool, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, - debug: bool, subject=None) -> {}: + debug: bool, subject: str = None) -> {}: """Send a report to moderators """ domainFull = getFullDomain(domain, port) @@ -1916,8 +1926,8 @@ def sendPost(projectVersion: str, federationList: [], sendThreads: [], postLog: [], cachedWebfingers: {}, personCache: {}, isArticle: bool, - debug=False, inReplyTo=None, - inReplyToAtomUri=None, subject=None) -> int: + debug: bool = False, inReplyTo: str = None, + inReplyToAtomUri: str = None, subject: str = None) -> int: """Post to another inbox """ withDigest = True @@ -2035,8 +2045,10 @@ def sendPostViaServer(projectVersion: str, attachImageFilename: str, mediaType: str, imageDescription: str, city: str, cachedWebfingers: {}, personCache: {}, - isArticle: bool, debug=False, inReplyTo=None, - inReplyToAtomUri=None, subject=None) -> int: + isArticle: bool, debug: bool = False, + inReplyTo: str = None, + inReplyToAtomUri: str = None, + subject: str = None) -> int: """Send a post via a proxy (c2s) """ if not session: @@ -2784,7 +2796,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=None) -> {}: + pageNumber: int = None) -> {}: return _createBoxIndexed(recentPostsCache, session, baseDir, 'inbox', nickname, domain, port, httpPrefix, @@ -2794,7 +2806,7 @@ def createInbox(recentPostsCache: {}, def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, itemsPerPage: int, - headerOnly: bool, pageNumber=None) -> {}: + headerOnly: bool, pageNumber: int = None) -> {}: return _createBoxIndexed({}, session, baseDir, 'tlbookmarks', nickname, domain, port, httpPrefix, itemsPerPage, headerOnly, @@ -2804,7 +2816,7 @@ def createBookmarksTimeline(session, baseDir: str, nickname: str, domain: str, def createEventsTimeline(recentPostsCache: {}, session, baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, itemsPerPage: int, - headerOnly: bool, pageNumber=None) -> {}: + headerOnly: bool, pageNumber: int = None) -> {}: return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlevents', nickname, domain, port, httpPrefix, itemsPerPage, headerOnly, @@ -2814,7 +2826,7 @@ def createEventsTimeline(recentPostsCache: {}, def createDMTimeline(recentPostsCache: {}, session, baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, itemsPerPage: int, - headerOnly: bool, pageNumber=None) -> {}: + headerOnly: bool, pageNumber: int = None) -> {}: return _createBoxIndexed(recentPostsCache, session, baseDir, 'dm', nickname, domain, port, httpPrefix, itemsPerPage, @@ -2824,7 +2836,7 @@ def createDMTimeline(recentPostsCache: {}, def createRepliesTimeline(recentPostsCache: {}, session, baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, itemsPerPage: int, - headerOnly: bool, pageNumber=None) -> {}: + headerOnly: bool, pageNumber: int = None) -> {}: return _createBoxIndexed(recentPostsCache, session, baseDir, 'tlreplies', nickname, domain, port, httpPrefix, itemsPerPage, headerOnly, True, @@ -2833,7 +2845,7 @@ def createRepliesTimeline(recentPostsCache: {}, def createBlogsTimeline(session, baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, itemsPerPage: int, - headerOnly: bool, pageNumber=None) -> {}: + headerOnly: bool, pageNumber: int = None) -> {}: return _createBoxIndexed({}, session, baseDir, 'tlblogs', nickname, domain, port, httpPrefix, itemsPerPage, headerOnly, True, @@ -2842,7 +2854,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=None) -> {}: + headerOnly: bool, pageNumber: int = None) -> {}: return _createBoxIndexed({}, session, baseDir, 'tlfeatures', nickname, domain, port, httpPrefix, itemsPerPage, headerOnly, True, @@ -2851,7 +2863,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=None) -> {}: + headerOnly: bool, pageNumber: int = None) -> {}: return _createBoxIndexed({}, session, baseDir, 'tlmedia', nickname, domain, port, httpPrefix, itemsPerPage, headerOnly, True, @@ -2862,7 +2874,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=None) -> {}: + pageNumber: int = None) -> {}: return _createBoxIndexed({}, session, baseDir, 'outbox', 'news', domain, port, httpPrefix, itemsPerPage, headerOnly, True, @@ -2873,7 +2885,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=None) -> {}: + pageNumber: int = None) -> {}: return _createBoxIndexed({}, session, baseDir, 'outbox', nickname, domain, port, httpPrefix, itemsPerPage, headerOnly, authorized, @@ -2882,7 +2894,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=None) -> {}: + pageNumber: int = None) -> {}: boxDir = createPersonDir(nickname, domain, baseDir, 'inbox') boxname = 'moderation' @@ -3137,7 +3149,7 @@ def _createBoxIndexed(recentPostsCache: {}, nickname: str, domain: str, port: int, httpPrefix: str, itemsPerPage: int, headerOnly: bool, authorized: bool, newswireVotesThreshold: int, positiveVoting: bool, - votingTimeMins: int, pageNumber=None) -> {}: + votingTimeMins: int, pageNumber: int = None) -> {}: """Constructs the box feed for a person with the given nickname """ if not authorized or not pageNumber: @@ -3611,9 +3623,9 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str, def downloadFollowCollection(followType: str, - session, httpPrefix, - actor: str, pageNumber=1, - noOfPages=1, debug=False) -> []: + session, httpPrefix: str, + actor: str, pageNumber: int = 1, + noOfPages: int = 1, debug: bool = False) -> []: """Returns a list of following/followers for the given actor by downloading the json for their following/followers collection """ diff --git a/session.py b/session.py index c1ad5087e..0c4de0b39 100644 --- a/session.py +++ b/session.py @@ -84,8 +84,9 @@ def urlExists(session, url: str, timeoutSec=3, def getJson(session, url: str, headers: {}, params: {}, debug: bool, - version='1.2.0', httpPrefix='https', - domain='testdomain', timeoutSec=20, quiet=False) -> {}: + version: str = '1.2.0', httpPrefix: str = 'https', + domain: str = 'testdomain', + timeoutSec: int = 20, quiet: bool = False) -> {}: if not isinstance(url, str): if debug and not quiet: print('url: ' + str(url)) @@ -149,7 +150,8 @@ def getJson(session, url: str, headers: {}, params: {}, debug: bool, def postJson(session, postJsonObject: {}, federationList: [], - inboxUrl: str, headers: {}, timeoutSec=60, quiet=False) -> str: + inboxUrl: str, headers: {}, timeoutSec: int = 60, + quiet: bool = False) -> str: """Post a json message to the inbox of another person """ # check that we are posting to a permitted domain @@ -195,8 +197,8 @@ def postJsonString(session, postJsonStr: str, inboxUrl: str, headers: {}, debug: bool, - timeoutSec=30, - quiet=False) -> (bool, bool): + timeoutSec: int = 30, + quiet: bool = False) -> (bool, bool): """Post a json message string to the inbox of another person The second boolean returned is true if the send is unauthorized NOTE: Here we post a string rather than the original json so that diff --git a/utils.py b/utils.py index ce35bab49..0905a810f 100644 --- a/utils.py +++ b/utils.py @@ -110,7 +110,8 @@ def hasUsersPath(pathStr: str) -> bool: return False -def validPostDate(published: str, maxAgeDays=90, debug=False) -> bool: +def validPostDate(published: str, maxAgeDays: int = 90, + debug: bool = False) -> bool: """Returns true if the published date is recent and is not in the future """ baselineTime = datetime.datetime(1970, 1, 1) @@ -545,7 +546,7 @@ def loadJsonOnionify(filename: str, domain: str, onionDomain: str, return jsonObject -def getStatusNumber(publishedStr=None) -> (str, str): +def getStatusNumber(publishedStr: str = None) -> (str, str): """Returns the status number and published date """ if not publishedStr: @@ -1146,7 +1147,7 @@ def clearFromPostCaches(baseDir: str, recentPostsCache: {}, def locatePost(baseDir: str, nickname: str, domain: str, - postUrl: str, replies=False) -> str: + postUrl: str, replies: bool = False) -> str: """Returns the filename for the given status post url """ if not replies: @@ -1535,7 +1536,7 @@ def isPublicPost(postJsonObject: {}) -> bool: return False -def copytree(src: str, dst: str, symlinks=False, ignore=None): +def copytree(src: str, dst: str, symlinks: str = False, ignore: bool = None): """Copy a directory """ for item in os.listdir(src): diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py index e8dd68233..d6e397d10 100644 --- a/webapp_frontscreen.py +++ b/webapp_frontscreen.py @@ -98,8 +98,9 @@ def htmlFrontScreen(rssIconAtTop: bool, peertubeInstances: [], allowLocalNetworkAccess: bool, accessKeys: {}, - extraJson=None, - pageNumber=None, maxItemsPerPage=None) -> str: + extraJson: {} = None, + pageNumber: int = None, + maxItemsPerPage: int = None) -> str: """Show the news instance front screen """ nickname = profileJson['preferredUsername'] diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py index 1fbe2713e..cab2af8b8 100644 --- a/webapp_hashtagswarm.py +++ b/webapp_hashtagswarm.py @@ -21,7 +21,7 @@ from webapp_utils import htmlFooter def getHashtagCategoriesFeed(baseDir: str, - hashtagCategories=None) -> str: + hashtagCategories: {} = None) -> str: """Returns an rss feed for hashtag categories """ if not hashtagCategories: diff --git a/webapp_login.py b/webapp_login.py index c339c4ebf..72a0f3846 100644 --- a/webapp_login.py +++ b/webapp_login.py @@ -55,7 +55,7 @@ def htmlLogin(cssCache: {}, translate: {}, baseDir: str, httpPrefix: str, domain: str, systemLanguage: str, - autocomplete=True) -> str: + autocomplete: bool = True) -> str: """Shows the login screen """ accounts = noOfAccounts(baseDir) diff --git a/webapp_post.py b/webapp_post.py index 61139fb8c..f1f845b73 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -1159,11 +1159,11 @@ def individualPostAsHtml(allowDownloads: bool, peertubeInstances: [], allowLocalNetworkAccess: bool, themeName: str, - showRepeats=True, - showIcons=False, - manuallyApprovesFollowers=False, - showPublicOnly=False, - storeToCache=True) -> str: + showRepeats: bool = True, + showIcons: bool = False, + manuallyApprovesFollowers: bool = False, + showPublicOnly: bool = False, + storeToCache: bool = True) -> str: """ Shows a single post as html """ if not postJsonObject: diff --git a/webapp_profile.py b/webapp_profile.py index 59e21e653..5a08d2659 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -444,8 +444,8 @@ def htmlProfile(rssIconAtTop: bool, allowLocalNetworkAccess: bool, textModeBanner: str, debug: bool, accessKeys: {}, city: str, - extraJson=None, pageNumber=None, - maxItemsPerPage=None) -> str: + extraJson: {} = None, pageNumber: int = None, + maxItemsPerPage: int = None) -> str: """Show the profile page as html """ nickname = profileJson['preferredUsername'] diff --git a/webapp_utils.py b/webapp_utils.py index 4f077bd90..7797d040c 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -104,7 +104,7 @@ def _markdownReplaceQuotes(markdown: str) -> str: return result -def _markdownReplaceLinks(markdown: str, images=False) -> str: +def _markdownReplaceLinks(markdown: str, images: bool = False) -> str: """Replaces markdown links with html Optionally replace image links """ @@ -442,7 +442,7 @@ def setBlogAddress(actorJson: {}, blogAddress: str) -> None: def updateAvatarImageCache(session, baseDir: str, httpPrefix: str, actor: str, avatarUrl: str, personCache: {}, allowDownloads: bool, - force=False, debug=False) -> str: + force: bool = False, debug: bool = False) -> str: """Updates the cached avatar for the given actor """ if not avatarUrl: @@ -1327,9 +1327,9 @@ def htmlHideFromScreenReader(htmlStr: str) -> str: def htmlKeyboardNavigation(banner: str, links: {}, accessKeys: {}, - subHeading=None, - usersPath=None, translate=None, - followApprovals=False) -> str: + subHeading: str = None, + usersPath: str = None, translate: {} = None, + followApprovals: bool = False) -> str: """Given a set of links return the html for keyboard navigation """ htmlStr = '