added toLWTH conversion if startLocation is rectLTRB#14671
Conversation
…ndingRects always returns rectLWTH
See test results for failed build of commit a60df41c12 |
|
Hi @FalkoBabbage, I don't think that change log description is appropriate for bug fixes. I'm also not sure if this description is specific enough:
What does it return instead now? Can you add typing information to Considering that |
|
Hi @seanbudd.
The origin of the error that I occurred is as follows:
Maybe the following is better to describe the changes:
In textInfos/init.py the _get_boundingRects method of the class TextInfo already specifies the return type locationHelper.RectLTWH in its comment. This is not enforced by the typing module and is just a comment.
Since |
|
Thanks for explaining the bug in more detail.
Can you please add typing information to the function header here. For example nvda/source/textInfos/offsets.py Line 182 in 474f228
Ah I see, makes sense. Thanks for explaining |
_get_boundingRects is defined in textInfos.TextInfo. I suggest to add the correct typing there if that is desired since I assume that any override would also be "forced" to use this type. Should |
|
I think it would be sufficient to just add it for the function you updated. |
… only startLocation is used to make _get_boundingRects
See test results for failed build of commit 9cac227d01 |
See test results for failed build of commit bd715df7a1 |
|
I do not understand the failed link check from appveyor:
Should I also reduce complexity of the function in order to do finish this pr? |
|
I have looked into reducing the complexity but as far as I know that would mean that I have to split up the function into different subfunctions. In that case we would end up with more methods in the OffsetsTextInfo class which should also make sense for its child-classes downstream. |
The linter only checks the code that you have modified. And among others, it checks the complexity of the functions that you have modified. It does not care if you reduced the complexity, it just check if it is too high or not. The original function was very too complex. But it has probably been written before the linter check was introduced. You have two options:
If it's not too much work and depending on the impact of the modifications, the first solution is preferred. This allows the code to converge towards a linted code. |
|
Either option @CyrilleB79 suggested here is appropriate. Search for |
|
I have decided to add a |
| return ", ".join(textList) | ||
|
|
||
| def _get_boundingRects(self): | ||
| def _get_boundingRects(self) -> List[locationHelper.RectLTWH]: # noqa: C901 |
There was a problem hiding this comment.
please see similar comments in the NVDA code base and apply the full message (search C901)
Link to issue number:
Fixes #12424
Summary of the issue:
JABTextInfo can return rectLTRB which is then used in the boudingRects property. this can be an issue for functions that expect rectLTWH types to be returned.
Description of user facing changes
None
Description of development approach
walked through where JABTextInfo could return a rectLTRB instance. found it
Testing strategy:
Ran runnvda.bat with adjusted code. Followed the steps in issue 12424 to reproduce the error and got a valid answer instead.
Known issues with pull request:
Change log entries:
New features
Changes
Bug fixes
For Developers
-offsets.OffsetsTextInfo._get_boundingRects return type is specified to List[locationHelper.rectLTWH] as conform to textInfos.TextInfo._get_boundingRects. offsets.OffsetsTextInfo._get_boundingRects is adjusted to always return the specified type.
Code Review Checklist: