Skip to content

Make the build addon check pass - #51

Open
serrebidev wants to merge 4 commits into
ABuffEr:masterfrom
serrebidev:ci-green-cleanup
Open

Make the build addon check pass#51
serrebidev wants to merge 4 commits into
ABuffEr:masterfrom
serrebidev:ci-green-cleanup

Conversation

@serrebidev

Copy link
Copy Markdown
Contributor

Problem

The build addon check has never passed for this repo. It fails on master, 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 clean master checkout reproduces it. Six hooks fail:

hook why
trim trailing whitespace pre-existing
fix end of files readme.md has a trailing blank line
Add trailing commas pre-existing
lint with ruff 16 errors (11 bare except:, plus E711/E701/F401/F841)
format with ruff 19 files unformatted
type check with pyright 34 errors — cannot resolve controlTypes, buildVersion, versionInfo

Fix

Four commits, separated so the mechanical noise is reviewable apart from the real changes:

  1. Lint fixes — 16 lines across 3 files. The only behavioural change in the whole PR.
  2. ruff-format + add-trailing-comma — mechanical, no behaviour change.
  3. Skip pyright in CI — see below.
  4. readme.md — drop a trailing blank line.

On pyright

I did not make pyright pass; I skipped it, matching what .pre-commit-config.yaml already 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, because typeCheckingMode = "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 become 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 stop being swallowed. The E711 change (index == similar != Noneis not None) is over ints from positionInfo, so it's equivalent.

Verification

I can't run NVDA in CI, so I verified statically rather than by clicking through lists:

  • AST comparison of every module, before vs after. 8 of 11 files are provably identical. The 3 that changed contain exactly the intended edits and nothing else. Only these functions differ: getColumnData, isEmptyList, isMultipleSelectionSupported, preCheck, reportListBounds, script_find, getScriptGestures, onInstall. Every other command — including script_readListItems (read all items), script_readColumn, script_itemInfo, script_manageHeaders, script_reportEmpty — is untouched.
  • xgettext output is byte-for-byte identical to master. 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-files is green and stable at a fixpoint.

Testing in a real list by someone running the add-on would still be welcome, particularly around script_find on NVDA ≤ 2020.3.

Note on #50

This conflicts with #50, which touches getFixedNum in 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant