Make the build addon check pass - #51
Open
serrebidev wants to merge 4 commits into
Open
Conversation
The "Code checks" CI step has never passed for this repo: `pre-commit run --all-files` reports 16 ruff errors on master. This fixes them: * E722 (x11): bare `except:` -> `except Exception:`. Both add-on exception types (noColumnAtIndex, columnAtIndexNotVisible) derive from Exception, as do COMError and watchdog.CallCancelled, so the same errors are still caught. Only KeyboardInterrupt/SystemExit are no longer swallowed. * E711: `index == similar != None` -> `index == similar is not None`. Both are chained comparisons over ints from positionInfo, so this is equivalent. * E701 (x2): split `if x: y` onto two lines. No AST change. * F401: drop unused `CTWRAPPER` import in commonFunc (nothing re-exports it; __init__ imports it from .compat directly). * F841: drop dead `scriptGestures = []` assignment. Verified by comparing the AST of every module before and after: these are the only semantic changes, and they are confined to getColumnData, isEmptyList, isMultipleSelectionSupported, preCheck, reportListBounds, script_find, getScriptGestures and onInstall.
Mechanical reformatting only, to satisfy the `format with ruff` and `add trailing commas` pre-commit hooks. No behaviour change: the AST of every module is unchanged by this commit, apart from ruff dropping the redundant Python-2 `u"..."` prefixes (`u"x"` and `"x"` are the same str in Python 3; only the syntactic `kind` marker differs). Where reformatting split a `_()` call across lines, the `# Translators:` comment is moved down so it still immediately precedes the line holding the message. xgettext attaches a comment to the *string* line, so without this 9 translator comments would have silently dropped out of the .pot. `xgettext` output for the whole add-on is byte-for-byte identical to master, so translations and the .pot are unaffected.
pyright is configured (pyproject.toml) to load NVDA from ../nvda/source, but
the workflow never checks NVDA out, so controlTypes / buildVersion /
versionInfo are all unresolved and the hook fails with 34 errors on master.
.pre-commit-config.yaml already skips pyright on pre-commit.ci for this exact
reason ("Pyright does not seem to work in pre-commit CI"); this applies the
same skip to the GitHub Actions run, which is the only thing still keeping
the check red.
Checking NVDA out on the runner is not a workable alternative: with
../nvda/source present, pyright resolves the imports and then reports 2357
errors, because typeCheckingMode = "strict" requires annotations this
add-on does not have. Making pyright meaningful here needs a typing pass on
the whole add-on, which is well out of scope for unblocking CI.
Satisfies the end-of-file-fixer pre-commit hook, which also fails on master.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
build addoncheck has never passed for this repo. It fails onmaster, on every PR, and on all five of the most recent workflow runs — so every pull request arrives with a red X that says nothing about the pull request.Running the CI step locally (
SKIP=no-commit-to-branch pre-commit run --all-files) on a cleanmastercheckout reproduces it. Six hooks fail:trim trailing whitespacefix end of filesreadme.mdhas a trailing blank lineAdd trailing commaslint with ruffexcept:, plus E711/E701/F401/F841)format with rufftype check with pyrightcontrolTypes,buildVersion,versionInfoFix
Four commits, separated so the mechanical noise is reviewable apart from the real changes:
ruff-format+add-trailing-comma— mechanical, no behaviour change.readme.md— drop a trailing blank line.On pyright
I did not make pyright pass; I skipped it, matching what
.pre-commit-config.yamlalready does for pre-commit.ci ("Pyright does not seem to work in pre-commit CI").The config points pyright at
../nvda/source, which CI never checks out. I tested the obvious fix — checking NVDA out so the imports resolve. It makes things much worse: errors go from 34 to 2357, becausetypeCheckingMode = "strict"demands annotations this add-on doesn't have. Making pyright meaningful here means a typing pass over the whole add-on, which is a separate project. Skipping it is the only thing that unblocks the check today.On the behavioural change
The 11 bare
except:clauses becomeexcept Exception:. Both add-on exception types (noColumnAtIndex,columnAtIndexNotVisible) derive fromException, as doCOMErrorandwatchdog.CallCancelled, so the same errors are still caught — onlyKeyboardInterrupt/SystemExitstop being swallowed. TheE711change (index == similar != None→is not None) is over ints frompositionInfo, so it's equivalent.Verification
I can't run NVDA in CI, so I verified statically rather than by clicking through lists:
getColumnData,isEmptyList,isMultipleSelectionSupported,preCheck,reportListBounds,script_find,getScriptGestures,onInstall. Every other command — includingscript_readListItems(read all items),script_readColumn,script_itemInfo,script_manageHeaders,script_reportEmpty— is untouched.xgettextoutput is byte-for-byte identical tomaster. This one caught a real bug: reformatting split several_()calls across lines, which detached 9# Translators:comments and silently dropped them from the.pot. Commit 2 moves each comment to sit directly above its message string, which restores the pot exactly.pre-commit run --all-filesis green and stable at a fixpoint.Testing in a real list by someone running the add-on would still be welcome, particularly around
script_findon NVDA ≤ 2020.3.Note on #50
This conflicts with #50, which touches
getFixedNumin a region this reformats. Happy to rebase #50 on top of this once you've picked an order — or to drop/split any of these commits if you'd rather not take the formatting churn.