UIA handler reorganization: gather UIA modules into a public "UIAHandler" package#13089
Conversation
… public module. Re nvaccess#10916. When UIA handler first appeared in 2008, it was housed in UIAHandler.py, the public-facing module. In 2011, a private _UIAHandler.py module was created to handle lack of usable UIA implementation in Windows XP, Server 2003, and older releases of Windows Vista and Server 2008. Since NVDA 2017.4, Windows 7 SP1 and Server 2008 R2 SP1 are required, meaning a usable UIA implementation is available. For backward compatibility, the private/public split was kept. Recognizing maintenance issues with private/public module, a reorganization effort was proposed in 2020, with the work taking place in 2021. This effort aims to combine private and public UIA handler modules under one file, as well as bring UIA support modules under a package, similar to IAccessible handler reorganization in 2021. As a first step, contents of private UIA handler module is now part of public UIA handler, with other NVDA modules importing the private module to be edited to use the public module (later commit). Module header is based on a combination of both public and private modules. Combined module contents: 1. Module header 2. Public module contents (UIA handler object definition, init/terminate methods) placed between bulk of private module content and UIA debug check function
With the contents of the private module moved to public UIA handler module, there is no need to keep the private module around anymore. Therefore remove the private module.
…. Re nvaccess#10916. Reorganization: convert UIA handler from a module to a package (source/UIAHandler/__init__.py). The new UIA handler package will be home of various UIA related modules such as UIA custom properties and annotations support.
…m props, and custom annotations modules. Re nvaccess#10916
Import changes: * _UIAConstants -> UIAHandler.constants * _UIACustomAnnotations -> UIAHandler.customAnnocations * _UIACustomProps -> UIAHandler.customProps
…ndler. Re nvaccess#10916. Transfer UIA utils module to UIA handler package, along with editing UIA constants module import to be relative import.
…and custom props modules as contents were transferred to UIA handler package and renamed. Re nvaccess#10916
…IA handler and was renamed to utils. Re nvaccess#10916
… rename it to browseMode.py. Re nvaccess#10916
… to UIA handler package and renamed. Re nvaccess#10916
In addition to resolving lint issues (Flake8), linted UIAHandler.handler.getNearistWindowHandle method.
…omRange import from UIAHandler.browseMode module as it is not used. Re nvaccess#10916. According to Flake8, UIAHandler.utils.getUIATextAttributeValueFromRange is imported but unused in UIAHandler.browseMode.py, therefore remove this import.
seanbudd
left a comment
There was a problem hiding this comment.
This generally looks good to me.
I would also consider moving all/most of the constants at the top of source/UIAHandler/__init__.py into separate files within the module.
This could be done in a follow up PR to make reviewing this PR easier.
Additionally, merging this PR will require reviews and feedback from other developers.
| return False | ||
|
|
||
|
|
||
| handler: Optional[UIAHandler] = None |
There was a problem hiding this comment.
This, and the initialization code, might be better suited to the top of file
There was a problem hiding this comment.
I agree it would be nicer. The only problem you may encounter would be a Linter complain about UIAHandler not being defined yet. This can be easily worked around either by:
- placing
UIAHandlerin quotes or - moving
UIAHandlerto a separate file, though this should happen in a follow up.
|
Hi, I think it would be best if someone takes care of splitting constants, event definitions, and related things to a separate file after creating an issue/PR pair discussing it. As for init code, it is at the bottom because Python wants class definitions to come before code that instantiates it (at least in my experience as well as looking at other modules with initialize/terminate functions defined). Thanks.
|
| return False | ||
|
|
||
|
|
||
| handler: Optional[UIAHandler] = None |
There was a problem hiding this comment.
I agree it would be nicer. The only problem you may encounter would be a Linter complain about UIAHandler not being defined yet. This can be easily worked around either by:
- placing
UIAHandlerin quotes or - moving
UIAHandlerto a separate file, though this should happen in a follow up.
|
Hi, As for a follow-up issue/PR pair, I guess it will discuss splitting UIA handler main module into two or more files. While we are at it, I think a long-term proposal would be to provide similar interfaces/modules between IAccessible and UIA handlers (and perhaps add JAB handler to the mix later), perhaps in 2023 cycle. Thanks. |
…ttribute from that module is used. Re nvaccess#10916. Comment from Lukasz Golonka: since word document module (UIA) imports UIAHandler.utils but no attribute is used, remove the import altogether.
|
Hi, As for putting initialize/terminate/handler class at the top of the UIA handler main module, I think it would be best to do it as part of a follow-up pull request that splits the main UIA module into two or more files. That way not only we can take care of this, but also lets us lint changes. Thanks. |
feerrenrut
left a comment
There was a problem hiding this comment.
Looks good to me.
Let's get this merged in and monitor for issues. Good work @josephsl
Link to issue number:
Closes #10916
Summary of the issue:
The bulk of UIA support code resides in a private UIA handler module (_UIAHandler.py). It was done that way to support Windows releases without usable UIA implementations such as Windows XP. Also, other UIA support modules such as custom annotations were added to support specific UIA scenarios.
Description of how this pull request fixes the issue:
Reorganized UIA handler as follows:
Testing strategy:
Manual, unit, and system tests:
Known issues with pull request:
None (haven't found add-ons that use the old modules)
Change log entries:
Changes for developers:
UIA handler module and other UIA support modules are now part of UIAHandler package. (#10916
Then mention the renamed files:
Code Review Checklist: