diff --git a/auth.py b/auth.py index 02db756c6..5103365f3 100644 --- a/auth.py +++ b/auth.py @@ -202,7 +202,7 @@ def authorize(baseDir: str, path: str, authHeader: str, debug: bool) -> bool: return False -def createPassword(length=10): +def createPassword(length: int = 10): validChars = 'abcdefghijklmnopqrstuvwxyz' + \ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' return ''.join((secrets.choice(validChars) for i in range(length))) diff --git a/blocking.py b/blocking.py index c26b07728..d7a1d8944 100644 --- a/blocking.py +++ b/blocking.py @@ -741,7 +741,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None: setConfigParam(baseDir, "brochMode", enabled) -def brochModeLapses(baseDir: str, lapseDays=7) -> bool: +def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool: """After broch mode is enabled it automatically elapses after a period of time """ diff --git a/desktop_client.py b/desktop_client.py index 9cf3d799f..0e2b0bd85 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -340,7 +340,7 @@ def _speakerPicospeaker(pitch: int, rate: int, systemLanguage: str, os.system(speakerCmd) -def _playNotificationSound(soundFilename: str, player='ffplay') -> None: +def _playNotificationSound(soundFilename: str, player: str = 'ffplay') -> None: """Plays a sound """ if not os.path.isfile(soundFilename): diff --git a/happening.py b/happening.py index 25ff7ff67..fde5f1e1f 100644 --- a/happening.py +++ b/happening.py @@ -19,7 +19,7 @@ from utils import locatePost from utils import hasObjectDict -def _validUuid(testUuid: str, version=4): +def _validUuid(testUuid: str, version: int = 4): """Check if uuid_to_test is a valid UUID """ try: diff --git a/media.py b/media.py index 0206a10ba..97bbc2f96 100644 --- a/media.py +++ b/media.py @@ -267,7 +267,8 @@ def attachMedia(baseDir: str, httpPrefix: str, return postJson -def archiveMedia(baseDir: str, archiveDirectory: str, maxWeeks=4) -> None: +def archiveMedia(baseDir: str, archiveDirectory: str, + maxWeeks: int = 4) -> None: """Any media older than the given number of weeks gets archived """ if maxWeeks == 0: diff --git a/pyjsonld.py b/pyjsonld.py index 36d0df1fa..fec0a1e34 100644 --- a/pyjsonld.py +++ b/pyjsonld.py @@ -4298,7 +4298,8 @@ class JsonLdProcessor(object): elif v not in urls: urls[v] = False - def _retrieve_context_urls(self, input_, cycles, load_document, base=''): + def _retrieve_context_urls(self, input_, cycles, load_document, + base: str = ''): """ Retrieves external @context URLs using the given document loader. Each instance of @context in the input that refers to a URL will be @@ -4860,7 +4861,7 @@ class ActiveContextCache(object): the overhead of recomputing them. """ - def __init__(self, size=100): + def __init__(self, size: int = 100): self.order = deque() self.cache = {} self.size = size diff --git a/session.py b/session.py index 7e48cde5a..b1f0b8d89 100644 --- a/session.py +++ b/session.py @@ -53,8 +53,8 @@ def createSession(proxyType: str): return session -def urlExists(session, url: str, timeoutSec=3, - httpPrefix='https', domain='testdomain') -> bool: +def urlExists(session, url: str, timeoutSec: int = 3, + httpPrefix: str = 'https', domain: str = 'testdomain') -> bool: if not isinstance(url, str): print('url: ' + str(url)) print('ERROR: urlExists failed, url should be a string') diff --git a/siteactive.py b/siteactive.py index c5e96f821..3fb7173e9 100644 --- a/siteactive.py +++ b/siteactive.py @@ -93,7 +93,7 @@ def _siteActiveHttpRequest(loc, timeout: int): return result -def siteIsActive(url: str, timeout=10) -> bool: +def siteIsActive(url: str, timeout: int = 10) -> bool: """Returns true if the current url is resolvable. This can be used to check that an instance is online before trying to send posts to it. diff --git a/threads.py b/threads.py index fa9ab9acd..d49981f90 100644 --- a/threads.py +++ b/threads.py @@ -71,7 +71,7 @@ class threadWithTrace(threading.Thread): def removeDormantThreads(baseDir: str, threadsList: [], debug: bool, - timeoutMins=30) -> None: + timeoutMins: int = 30) -> None: """Removes threads whose execution has completed """ if len(threadsList) == 0: diff --git a/utils.py b/utils.py index 434b07132..7360d4a23 100644 --- a/utils.py +++ b/utils.py @@ -153,7 +153,7 @@ def getFullDomain(domain: str, port: int) -> str: def isDormant(baseDir: str, nickname: str, domain: str, actor: str, - dormantMonths=3) -> bool: + dormantMonths: int = 3) -> bool: """Is the given followed actor dormant, from the standpoint of the given account """ @@ -544,7 +544,7 @@ def saveJson(jsonObject: {}, filename: str) -> bool: return False -def loadJson(filename: str, delaySec=2, maxTries=5) -> {}: +def loadJson(filename: str, delaySec: int = 2, maxTries: int = 5) -> {}: """Makes a few attempts to load a json formatted file """ jsonObject = None @@ -564,7 +564,7 @@ def loadJson(filename: str, delaySec=2, maxTries=5) -> {}: def loadJsonOnionify(filename: str, domain: str, onionDomain: str, - delaySec=2) -> {}: + delaySec: int = 2) -> {}: """Makes a few attempts to load a json formatted file This also converts the domain name to the onion domain """ @@ -2163,7 +2163,7 @@ def mediaFileMimeType(filename: str) -> str: return extensions[fileExt] -def isRecentPost(postJsonObject: {}, maxDays=3) -> bool: +def isRecentPost(postJsonObject: {}, maxDays: int = 3) -> bool: """ Is the given post recent? """ if not hasObjectDict(postJsonObject): diff --git a/webapp_media.py b/webapp_media.py index 5ef899fe0..bf666063b 100644 --- a/webapp_media.py +++ b/webapp_media.py @@ -32,7 +32,7 @@ def loadPeertubeInstances(baseDir: str, peertubeInstances: []) -> None: def _addEmbeddedVideoFromSites(translate: {}, content: str, peertubeInstances: [], - width=400, height=300) -> str: + width: int = 400, height: int = 300) -> str: """Adds embedded videos """ if '>vimeo.com/' in content: