You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NVDA API must maintain compatibility with add-ons throughout yearly development cycles.
2
6
The first release of a year, i.e. `20XX.1`, is when the NVDA API can introduce breaking changes.
3
7
4
-
In order to improve the NVDA API, changes that will break future compatibility can be implemented, as long they retain backwards compatibility until the `20XX.1` release.
8
+
## Deprecations
9
+
Where possible, ensure the NVDA API maintains backwards compatibility.
10
+
If no removal is required or proposed, backwards compatibility can be maintained via the following snippet:
11
+
12
+
```py
13
+
import globalVars
14
+
def__getattr__(attrName: str) -> Any:
15
+
"""Module level `__getattr__` used to preserve backward compatibility."""
16
+
if attrName =="deprecatedSymbolName"and globalVars._allowDeprecatedAPI:
17
+
# Note: this should only log in situations where it will not be excessively noisy.
18
+
log.warning(
19
+
"Importing deprecatedSymbolName from here is deprecated. "
20
+
"Import X instead and do Y. "
21
+
)
22
+
# Ensure the API of deprecatedSymbolNameReplacement is the same as the deprecated symbol.
23
+
return deprecatedSymbolNameReplacement
24
+
raiseAttributeError(f"module {repr(__name__)} has no attribute {repr(attrName)}")
25
+
```
26
+
27
+
28
+
## Required API breaking changes
29
+
In order to improve the NVDA API, changes that will break future compatibility may be implemented, as long they retain backwards compatibility until the `20XX.1` release.
5
30
6
31
This can be done by using a version check to automate deprecation. For example, if you wish to replace usages of `foo` with `bar`. When we begin work on `NEXT_YEAR`, `foo` will no longer be part of the NVDA API and all internal usages must be removed prior.
7
32
```python
8
33
from buildVersion import version_year
9
-
if version_year <NEXT_YEAR:
34
+
import globalVars
35
+
if version_year <NEXT_YEARand globalVars._allowDeprecatedAPI:
10
36
foo = bar
11
37
```
12
38
39
+
## Testing backwards compatibility
40
+
13
41
To ensure a module retains the same symbol names being importable, check across versions what is imported using the NVDA python console.
14
42
```python
15
43
import controlTypes
@@ -19,3 +47,7 @@ dir(controlTypes)
19
47
Changes different to moving or renaming symbols need to be considered carefully with a different approach.
20
48
21
49
Any API breaking changes such as deprecations marked for removal should be commented with the year of intended removal, and notes on how to implement the API change as an add-on developer and NVDA developer.
50
+
51
+
## Announcements
52
+
Deprecations should be announced via the [NVDA API mailing list](https://groups.google.com/a/nvaccess.org/g/nvda-api/about).
This guide provides information concerning NVDA development, including translation and the development of components for NVDA.
14
14
15
+
++ API stability ++
16
+
The NVDA API only includes symbols which are not marked with prefixing underscores.
17
+
18
+
The NVDA Add-on API changes over time, such as removals, deprecations and new features.
19
+
Important changes to the API are announced on the [NVDA API mailing list https://groups.google.com/a/nvaccess.org/g/nvda-api/about].
20
+
21
+
API breaking releases happen at most once per year, these are ``.1`` releases, e.g. ``2022.1``.
22
+
The API remains backwards compatible between breaking releases.
23
+
API breaking changes should be considered relatively stable in the first beta: e.g. ``2022.1.beta1``.
24
+
25
+
API features may become deprecated over time.
26
+
Deprecated API features may have a scheduled removal date, a future breaking release (e.g. ``2022.1``).
27
+
Deprecations may also have no scheduled removal date, and will remain supported until it is no longer reasonable.
28
+
Note, the roadmap for removals is 'best effort' and may be subject to change.
29
+
Please open a GitHub issue if these changes stop the API from meeting your needs.
30
+
15
31
++ A Note About Python ++
16
32
NVDA and its components are primarily written in the Python programming language.
17
33
It is not the goal of this guide to teach you Python, though examples are provided through out this guide which will help to familiarise you with the Python syntax.
0 commit comments