Move some helper functions from main IAccessibleHandler module to satisfy Linter and decrease likelihood of circular imports#12367
Conversation
|
cc @feerrenrut @seanbudd While I'm pretty sure this PR is not going to break backward compatibility it would be nice to merge it before 2021.1 just to be on the safe side. It is very low impact yet eliminating cases in which particular order of imports is required is always good IMHO. |
|
Thanks @lukaszgo1. I agree that the code should be moved, and these changes look like a good end result. When performing the other large code refactor we came up with some problems:
With the other refactor, we removed linting so that a large linting change with an |
ca60a66 to
dd54ef6
Compare
I've tested with my daily NVDA config (around 20 add-ons) and while this is not an exhaustive list by any means I haven't seen any errors aside from #12399 which is not caused by this PR.
I'm not really sure why git blame fails to track these changes without ignoring white spaces since I've copied these functions verbatim (they were linted already). The only changes, aside from moving them, was to just add missing imports and copyright header to the new files. I agree that being able to track these moves is important so if you have a better idea for restructuring these commits so that git blame is able to detect these moves please do tell. |
…k around circular import
…leHandler.utils to workaround a circular import
…AccessibleHandler.types` to workaround circular import
dd54ef6 to
28d2a60
Compare
Okay great, we should really add system tests for this as #12399 should not have been introduced.
I think your IDE or git is changing the line endings of old code with LF to CRLF. You can fix this by:
I've done a rebase doing this if @feerrenrut or yourself could review? |
lukaszgo1
left a comment
There was a problem hiding this comment.
LGTM. Cannot approve since PR authors are unable to approve their own work.
Thanks - I'll investigate at which stage this fails on my machine to hopefully be able to avoid this issue next time. Assuming that this is changed by git and not by my editor can we enforce line endings through git config for all contributors? |
This would be good to have, we would also like to normalize all files to CRLF and add the commit to an ignore-revs file at some point |
seanbudd
left a comment
There was a problem hiding this comment.
LGTM, but will let @feerrenrut have a chance to have a look at it
|
Yep this looks ok. But I think there should be a description of these changes in the "for developers section", it may be unlikely, but we can't say it's impossible there are no addons relying on these things. |
b0bacac to
447172d
Compare
Link to issue number:
None - noticed when working on #12232
Summary of the issue:
Linter complains about various imports in IAccessibleHandler not being at the top of file. In the current situation moving them to the top causes errors about imports from not fully initialized module.
Description of how this pull request fixes the issue:
At first I thought this can be solved by not importing
NVDAObjects.IAccessiblein theapimodule which is unused there anyway. Unfortunately removing this import just delayed the error but NVDA still was unable to start. Therefore I've moved parts of IAccessibleHandler which are imported by various other files in this package to two new files:types.pycontains typing information forIAccessibleHandlerutils.pycontains various utility functions mostly introduced in Add significant optional debug logging for MSAA events #11521Testing strategy:
With git grep inspected all usages of the moved code ensured none were missed
Enabled MSAA logging category in the advanced settings and made sure than expected info is still logged.
Known issues with pull request:
None known
Change log entries:
None needed IMHO. I don't think anyone relied on the moved typing info - all other functions which were moved are imported back into
IAccessibleHandleranyway so backward compatibility is preserved.Code Review Checklist: