File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
123125def registerExecutableWithAppModule (executableName : str , appModName : str ) -> None :
Original file line number Diff line number Diff line change 1010For 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
1513from enum import Enum
1614import globalVars
1715import 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
Original file line number Diff line number Diff line change 66"""Utilities for working with the Windows Ease of Access Center.
77"""
88
9- from buildVersion import version_year
109from enum import Enum , IntEnum
1110from typing import List
11+
12+ import globalVars
1213from logHandler import log
1314import winreg
1415import 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
Original file line number Diff line number Diff line change @@ -69,3 +69,15 @@ class DefaultAppArgs(argparse.Namespace):
6969appPid : 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+ """
Original file line number Diff line number Diff line change 4646import speechViewer
4747import winUser
4848import 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 )
Original file line number Diff line number Diff line change @@ -85,12 +85,11 @@ Please test the new API and provide feedback.
8585For 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.
9493Code which imports from one of them, should instead import from the replacement module. (#13366)
9594-
9695
You can’t perform that action at this time.
0 commit comments