From 125e541e5e3e74c2c90eb4432eced3bdc365ddf7 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 22 Jan 2021 19:06:08 -0800 Subject: [PATCH] Annotations: annotate containers with no type information. Re #155. Mypy: annotate containers with no type information such as dictionaries and lists. This applies to both module-level and class attributes. --- addon/appModules/splcreator.py | 2 +- addon/appModules/splengine/encoders.py | 2 +- addon/appModules/splremotevt.py | 2 +- addon/appModules/splstudio/__init__.py | 6 +++--- addon/appModules/splstudio/splconfig.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addon/appModules/splcreator.py b/addon/appModules/splcreator.py index fe939f32d..cb4c27300 100755 --- a/addon/appModules/splcreator.py +++ b/addon/appModules/splcreator.py @@ -107,7 +107,7 @@ def isPlaylistEditor(self): SPLEditorDateTime = 0 SPLEditorDuration = 1 SPLEditorStatusBar = 2 - _playlistEditorStatusCache = {} + _playlistEditorStatusCache: dict[int, Any] = {} @scriptHandler.script(gesture="kb:alt+NVDA+1") def script_playlistDateTime(self, gesture): diff --git a/addon/appModules/splengine/encoders.py b/addon/appModules/splengine/encoders.py index 8bfeeb2b0..1f7f7de3d 100644 --- a/addon/appModules/splengine/encoders.py +++ b/addon/appModules/splengine/encoders.py @@ -38,7 +38,7 @@ # Use a thread to monitor status changes for encoders. SPLBackgroundMonitor = set() # A collection of encoder status monitor threads. -SPLBackgroundMonitorThreads = {} +SPLBackgroundMonitorThreads: dict[str, threading.Thread] = {} # Do not play connection tone while an encoder is connecting. SPLNoConnectionTone = set() # Stop announcing connection status messages when an error is encountered. diff --git a/addon/appModules/splremotevt.py b/addon/appModules/splremotevt.py index c7b277528..48194bf37 100644 --- a/addon/appModules/splremotevt.py +++ b/addon/appModules/splremotevt.py @@ -59,4 +59,4 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList): # Playlist editor is same as Creator except it responds a bit faster. # Without keeping a copy of status cache, NVDA will announce wrong values # as Creator app module's cache will be used. - _playlistEditorStatusCache = {} + _playlistEditorStatusCache: dict[int, Any] = {} diff --git a/addon/appModules/splstudio/__init__.py b/addon/appModules/splstudio/__init__.py index 6551e9544..40ef45b97 100644 --- a/addon/appModules/splstudio/__init__.py +++ b/addon/appModules/splstudio/__init__.py @@ -73,7 +73,7 @@ def new(*args, **kwargs): libScanT = None # Versions of Studio where library scanning functionality is broken. -noLibScanMonitor = [] +noLibScanMonitor: list[str] = [] # Braille and play a sound in response to an alarm or an event. @@ -1563,7 +1563,7 @@ def script_timeRangeFinder(self, gesture): # Cart explorer cartExplorer = False # The carts dictionary (key = cart gesture, item = cart name). - carts = {} + carts: dict[str, Any] = {} # Assigning and building carts. @@ -2227,7 +2227,7 @@ def script_SPLAssistantToggle(self, gesture): SPLTemperature: [7, 0], # Temperature for the current city. } - _cachedStatusObjs = {} + _cachedStatusObjs: dict[int, Any] = {} # Called in the layer commands themselves. # 16.11: in Studio 5.20, it is possible to obtain some of these via the API, hence the API method is used. diff --git a/addon/appModules/splstudio/splconfig.py b/addon/appModules/splstudio/splconfig.py index 0df6b6a93..17a4e8e24 100755 --- a/addon/appModules/splstudio/splconfig.py +++ b/addon/appModules/splstudio/splconfig.py @@ -35,7 +35,7 @@ # Cache a copy of the loaded config. # This comes in handy when saving configuration to disk. For the most part, no change occurs to config. # This helps prolong life of a solid-state drive (preventing unnecessary writes). -_SPLCache = {} +_SPLCache: dict[Optional[str], dict[Any, Any]] = {} # The following settings can be changed in profiles: _mutatableSettings = ("IntroOutroAlarms", "MicrophoneAlarm", "MetadataStreaming", "ColumnAnnouncement") # 7.0: Profile-specific confspec (might be removed once a more optimal way to validate sections is found).