Skip to content

Commit

Permalink
SPL track items/annotations: annotate SPL track item class methods ac…
Browse files Browse the repository at this point in the history
…ross base class and subclasses. Re #155.

Annotate class methods for SPL track item class and derivatives. This mostly concerns indexOf method, and for Studio version, additoinal methods.
  • Loading branch information
josephsl committed Jan 25, 2021
1 parent ac847aa commit b96ab8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions addon/appModules/splcreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# #155 (21.03): remove __future__ import when NVDA runs under Python 3.10.
from __future__ import annotations
from typing import Any
from typing import Any, Optional
import appModuleHandler
import addonHandler
import scriptHandler
Expand Down Expand Up @@ -40,14 +40,14 @@ class SPLCreatorItem(SPLTrackItem):
"""An entry in SPL Creator (mostly tracks).
"""

def indexOf(self, header):
def indexOf(self, header: str) -> Optional[int]:
try:
return indexOf(self.appModule.productVersion).index(header)
except ValueError:
return None

@property
def exploreColumns(self):
def exploreColumns(self) -> list[str]:
return splconfig.SPLConfig["General"]["ExploreColumnsCreator"]


Expand Down
12 changes: 6 additions & 6 deletions addon/appModules/splstudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _getColumnContentRaw(self, index):

# #103: provide an abstract index of function.
@abstractmethod
def indexOf(self, columnHeader):
def indexOf(self, columnHeader: str) -> Optional[int]:
return None

@scriptHandler.script(gesture="kb:control+alt+home")
Expand Down Expand Up @@ -291,7 +291,7 @@ def script_select(self, gesture):
# 8.0: Make this a public function.
# #109 (19.08): now standardized around this function.
# #142 (20.09): do not ignore Status column (0) just because it is the name of the track as reported by MSAA.
def indexOf(self, columnHeader):
def indexOf(self, columnHeader: str) -> Optional[int]:
try:
columnHeaders = ["Status"] + splconfig._SPLDefaults["ColumnAnnouncement"]["ColumnOrder"]
return columnHeaders.index(columnHeader)
Expand Down Expand Up @@ -344,7 +344,7 @@ def doAction(self, index=None):
# A convenience method that calls column content getter for a list of columns.
# Readable flag will transform None into an empty string, suitable for output.
# #61 (18.07): readable flag will become a string parameter to be used in columns viewer.
def _getColumnContents(self, columns=None, readable=False):
def _getColumnContents(self, columns: Optional[list[int]] = None, readable: bool = False) -> list[Optional[str]]:
if columns is None:
columns = list(range(18))
columnContents = [self._getColumnContentRaw(col) for col in columns]
Expand Down Expand Up @@ -391,7 +391,7 @@ def _moveToRow(self, row):
# Overlay class version of Columns Explorer.

@property
def exploreColumns(self):
def exploreColumns(self) -> list[str]:
return splconfig.SPLConfig["General"]["ExploreColumns"]

# Toggle screen column order.
Expand All @@ -418,7 +418,7 @@ def script_toggleScreenColumnOrder(self, gesture):
# Track comment announcer.
# Levels indicate what should be done.
# 0 indicates reportFocus, subsequent levels indicate script repeat count+1.
def announceTrackComment(self, level):
def announceTrackComment(self, level: int) -> None:
filename = self._getColumnContentRaw(self.indexOf("Filename"))
if filename is not None and filename in splconfig.trackComments:
if level == 0:
Expand Down Expand Up @@ -449,7 +449,7 @@ def announceTrackComment(self, level):
ui.message(_("Comments cannot be added to this kind of track"))

# A proxy function to call the track comments entry dialog.
def _trackCommentsEntry(self, filename, comment):
def _trackCommentsEntry(self, filename: str, comment: str) -> None:
dlg = wx.TextEntryDialog(
gui.mainFrame, _("Track comment"),
# Translators: The title of the track comments dialog.
Expand Down
5 changes: 3 additions & 2 deletions addon/appModules/tracktool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# #155 (21.03): remove __future__ import when NVDA runs under Python 3.10.
from __future__ import annotations
from typing import Optional
import appModuleHandler
import addonHandler
import tones
Expand Down Expand Up @@ -47,14 +48,14 @@ def reportFocus(self):
tones.beep(550, 100)
super(TrackToolItem, self).reportFocus()

def indexOf(self, header):
def indexOf(self, header: str) -> Optional[int]:
try:
return indexOf(self.appModule.productVersion).index(header)
except ValueError:
return None

@property
def exploreColumns(self):
def exploreColumns(self) -> list[str]:
return splconfig.SPLConfig["General"]["ExploreColumnsTT"]


Expand Down

0 comments on commit b96ab8e

Please sign in to comment.