Replace internal controlTypes.ROLE_* usages with controlTypes.Role.*#12649
Conversation
Searched using the regex [^\.]\bROLE_, which finds ROLE_ instances where * it is not of the form <Foo>.ROLE_ (as oleacc.ROLE_* exists) * ROLE_ is the prefix of the symbol (as IA2_ROLE_* exists) Replaced the remaining instances manually where required
See test results for failed build of commit d1eb87db3a |
|
I wonder whether we could emit deprecation warnings for old constant use, e.g. by handling them using a module getattr. For example: |
|
Hi, I think we will come across linting issues for a while, given how controlTypes.ROLE_* and STATE_* are used in places where Flake8 complains about various issues. Thanks. |
My first thought is that this would be way too noisy in this instance. I would want to do this for less integral parts of NVDA, or if the removal of the deprecation is delayed and most addons uses the new enums.
In this case I think it is best to be ignored and overridden with force merges. |
feerrenrut
left a comment
There was a problem hiding this comment.
Generally looks good. I've been through all the files.
A few files seem to have had their line endings modified, can you restore those?
Please don't force push, I'd like to be sure of which files have changed to make the follow up minimal.
| def _get_role(self) -> int: | ||
| def _get_role(self) -> controlTypes.Role: | ||
| """The role or type of control this object represents (example: button, list, dialog). | ||
| @return: a ROLE_* constant from L{controlTypes} |
There was a problem hiding this comment.
This comment should be updated as well to explain that now the role value comes from the enum
There was a problem hiding this comment.
I don't know what value that provides, the return type should make that clear hopefully
See test results for failed build of commit 6293c38132 |
See test results for failed build of commit c207ea8abd |
| def test_roleLabels(self): | ||
| """Test to check whether every role has its own display string""" | ||
| for role in controlTypes.Role: | ||
| role.displayString | ||
|
|
There was a problem hiding this comment.
Can you take a look to see if there is simple way to add a test for the corollary, that displayString raises when a label is missing?
If this test already exists, add a comment here to point it out.
There was a problem hiding this comment.
I don't think there is a simple way, as new members cannot be added to Role at run time. I've added a generic test for displayString.
If one adds a role and forgets to add a label, this test should fail assuming the displayString test still passes.
|
Given the nature of this change, I think it is clearer not to try to address lint changes. |
See test results for failed build of commit 4c575f6ecb |
feerrenrut
left a comment
There was a problem hiding this comment.
Tests look good. Might as well fix that copyright year. But I'm happy for you to merge this.
See test results for failed build of commit 3f943bbf64 |
|
@feerrenrut can you merge this - I am unable with the failed lint check |
See test results for failed build of commit 3f943bbf64 |
Related to #12649, #12712, #12836 Summary of the issue: The mentioned prs performed a large refactor with constant changes Description of user facing changes None known Description of development approach Add the mentioned PRs to .git-blame-ignore-revs to ensure a properly configured git blame will ignore these changes, revealing the history of the underlying code.
Link to issue number:
Part of #12549
Summary of the issue:
controlTypes.ROLE_*are deprecated, to be replaced bycontrolTypes.Role.*Description of how this pull request fixes the issue:
controlTypes.ROLE_withcontrolTypes.Role.across .py files[^\.]\bROLE_, which finds ROLE_ instanceswhere:
<Foo>.ROLE_(as oleacc.ROLE_* exists)Testing strategy:
Manual testing
Existing unit tests exist for controlTypes, new unit tests are written to ensure displayString works
Existing system tests will work as a basic smoke test for this core feature
Known issues with pull request:
The lint check is likely to fail
Change log entries:
None needed
Code Review Checklist: