Skip to content

Commit

Permalink
Type annotations: use __future__.annotations flag for backward and fo…
Browse files Browse the repository at this point in the history
…rward compatibility. Re #155.

Annotate functions and variables to make it clear as to what is what and what type it is. As a first step, use __future__.annotations import to guarantee forward and backward compatibility (to be removed in Python 3.10 version). This is better than importing uppercase versions of containers from typing module as these are deprecated in Python 3.9.
The overall type annotations are guided by Mypy, a static type checker.
  • Loading branch information
josephsl committed Jan 23, 2021
1 parent 14551f6 commit 2a212b2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addon/appModules/splcreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

# Basic support for StationPlaylist Creator.

# #155 (21.03): remove __future__ import when NVDA runs under Python 3.10.
from __future__ import annotations
from typing import Any
import appModuleHandler
import addonHandler
import scriptHandler
Expand Down
2 changes: 2 additions & 0 deletions addon/appModules/splengine/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Copyright 2015-2021 Joseph Lee, released under GPL.
# Split from main global plugin in 2015, transferred to SPL Engine app module in 2020.

# #155 (21.03): remove __future__ import when NVDA runs under Python 3.10.
from __future__ import annotations
import threading
import time
import os
Expand Down
3 changes: 3 additions & 0 deletions addon/appModules/splremotevt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Basic support for StationPlaylist Remote VT Client.
# Borrows heavily from creator as the user interface is quite similar with changes specific to VT Client.

# #155 (21.03): remove __future__ import when NVDA runs under Python 3.10.
from __future__ import annotations
from typing import Any
import addonHandler
import globalVars
import ui
Expand Down
3 changes: 3 additions & 0 deletions addon/appModules/splstudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

# Minimum version: SPL 5.30, NVDA 2020.3.

# #155 (21.03): remove __future__ import when NVDA runs under Python 3.10.
from __future__ import annotations
from typing import Any
from functools import wraps
import os
import time
Expand Down
3 changes: 3 additions & 0 deletions addon/appModules/splstudio/splconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# For UI surrounding this module, see splconfui module.
# For the add-on settings specification, see splconfspec module.

# #155 (21.03): remove __future__ import when NVDA runs under Python 3.10.
from __future__ import annotations
from typing import Optional, Any
import os
import pickle
from collections import ChainMap
Expand Down

0 comments on commit 2a212b2

Please sign in to comment.