Skip to content

Commit 70f38a5

Browse files
authored
Merge 3b0022f into 424afaf
2 parents 424afaf + 3b0022f commit 70f38a5

6 files changed

Lines changed: 34 additions & 28 deletions

File tree

source/appModuleHandler.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __getattr__(attrName: str) -> Any:
8989
since add-ons are initialized before `appModuleHandler`
9090
and when `appModuleHandler` was not yet initialized the variable was set to `None`.
9191
"""
92-
if attrName == "NVDAProcessID":
92+
if attrName == "NVDAProcessID" and globalVars._useDeprecatedAPI:
9393
log.warning("appModuleHandler.NVDAProcessID is deprecated, use globalVars.appPid instead.")
9494
if initialize._alreadyInitialized:
9595
return globalVars.appPid
@@ -112,12 +112,14 @@ def _warnDeprecatedAliasAppModule() -> None:
112112
except KeyError:
113113
raise RuntimeError("This function can be executed only inside an alias App Module.") from None
114114
else:
115-
log.warning(
116-
(
117-
f"Importing from appModules.{currModName} is deprecated,"
118-
f" you should import from appModules.{replacementModName}."
119-
)
115+
importFailMsg = (
116+
f"Importing appModules.{currModName} is deprecated,"
117+
f" instead import appModules.{replacementModName}."
120118
)
119+
if globalVars._useDeprecatedAPI:
120+
log.warning(importFailMsg)
121+
else:
122+
raise ModuleNotFoundError(importFailMsg)
121123

122124

123125
def registerExecutableWithAppModule(executableName: str, appModName: str) -> None:

source/config/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
For the latter two actions, one can perform actions prior to and/or after they take place.
1111
"""
1212

13-
14-
from buildVersion import version_year
1513
from enum import Enum
1614
import globalVars
1715
import winreg
@@ -88,17 +86,15 @@ class RegistryKey(str, Enum):
8886
"""
8987

9088

91-
if version_year < 2023:
89+
if globalVars._useDeprecatedAPI:
9290
RUN_REGKEY = RegistryKey.RUN.value
9391
"""
94-
Deprecated, for removal in 2023.
95-
Use L{RegistryKey.RUN} instead.
92+
Deprecated, use L{RegistryKey.RUN} instead.
9693
"""
9794

9895
NVDA_REGKEY = RegistryKey.NVDA.value
9996
"""
100-
Deprecated, for removal in 2023.
101-
Use L{RegistryKey.NVDA} instead.
97+
Deprecated, use L{RegistryKey.NVDA} instead.
10298
"""
10399

104100

source/easeOfAccess.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"""Utilities for working with the Windows Ease of Access Center.
77
"""
88

9-
from buildVersion import version_year
109
from enum import Enum, IntEnum
1110
from typing import List
11+
12+
import globalVars
1213
from logHandler import log
1314
import winreg
1415
import winUser
@@ -32,20 +33,18 @@ class AutoStartContext(IntEnum):
3233
AFTER_LOGON = winreg.HKEY_CURRENT_USER
3334

3435

35-
if version_year < 2023:
36+
if globalVars._useDeprecatedAPI:
3637
ROOT_KEY = RegistryKey.ROOT.value
3738
"""
38-
Deprecated, for removal in 2023.
39-
Use L{RegistryKey.ROOT} instead.
39+
Deprecated, use L{RegistryKey.ROOT} instead.
4040
"""
4141

4242
APP_KEY_NAME = _APP_KEY_NAME
43-
"""Deprecated, for removal in 2023"""
43+
"""Deprecated for removal"""
4444

4545
APP_KEY_PATH = RegistryKey.APP.value
4646
"""
47-
Deprecated, for removal in 2023.
48-
Use L{RegistryKey.APP} instead.
47+
Deprecated, use L{RegistryKey.APP} instead.
4948
"""
5049

5150

source/globalVars.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,15 @@ class DefaultAppArgs(argparse.Namespace):
6969
appPid: int = 0
7070
"""The process ID of NVDA itself.
7171
"""
72+
73+
_useDeprecatedAPI: bool = True
74+
"""
75+
Used for marking code as deprecated.
76+
This should never be False in released code.
77+
78+
Making this False may be useful for testing if code
79+
is compliant without using deprecated APIs.
80+
Note that deprecated code may be imported at runtime,
81+
and as such, this value cannot be changed at runtime
82+
to test compliance.
83+
"""

source/gui/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@
4646
import speechViewer
4747
import winUser
4848
import api
49-
from buildVersion import version_year
5049

5150

52-
if version_year < 2023:
51+
if globalVars._useDeprecatedAPI:
5352
def quit():
5453
"""
55-
Deprecated, for removal in 2023.1.
56-
Use `wx.CallAfter(mainFrame.onExitCommand, None)` directly instead.
54+
Deprecated, use `wx.CallAfter(mainFrame.onExitCommand, None)` directly instead.
5755
"""
5856
log.debugWarning("Deprecated function called: gui.quit", stack_info=True)
5957
wx.CallAfter(mainFrame.onExitCommand, None)

user_docs/en/changes.t2t

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ Please test the new API and provide feedback.
8585
For add-on authors, please open a GitHub issue if these changes stop the API from meeting your needs.
8686

8787

88-
- ``appModuleHandler.NVDAProcessID`` is deprecated - use ``globalVars.appPid`` instead. (#13646)
89-
- ``gui.quit`` has been deprecated for removal in 2023.1. (#13498)
90-
- Use ``wx.CallAfter(mainFrame.onExitCommand, None)`` directly instead.
88+
- ``appModuleHandler.NVDAProcessID`` is deprecated, use ``globalVars.appPid`` instead. (#13646)
89+
- ``gui.quit`` is deprecated, use ``wx.CallAfter(mainFrame.onExitCommand, None)`` instead. (#13498)
9190
-
9291
% Insert new list items here as the alias appModule table should be kept at the bottom of this list
93-
- Some alias appModules are marked as deprecated and will be removed in 2023.1.
92+
- Some alias appModules are marked as deprecated.
9493
Code which imports from one of them, should instead import from the replacement module. (#13366)
9594
-
9695

0 commit comments

Comments
 (0)