Skip to content

Run runlint.bat on scons and .pyw files#19922

Open
christopherpross wants to merge 6 commits intonvaccess:masterfrom
christopherpross:fix-ruff-format-scons-files
Open

Run runlint.bat on scons and .pyw files#19922
christopherpross wants to merge 6 commits intonvaccess:masterfrom
christopherpross:fix-ruff-format-scons-files

Conversation

@christopherpross
Copy link
Copy Markdown
Contributor

@christopherpross christopherpross commented Apr 8, 2026

Must be merge commit, not squash merge (to preserve the commit hash in .git-blame-ignore-revs)

Link to issue number:

No issue created. If a separate issue is needed or anything about this PR should be handled differently, please let me know. I oriented myself on how similar PRs were done in the past (e.g. #16803, #16936).

Summary of the issue:

runlint.bat on a clean master produces changes in 6 files. As discussed in #19907, these files are not recognized as Python by pre-commit CI on Linux (see also pre-commit/identify#563), so they were never auto-formatted. Same applies to add-trailing-comma.

Description of user facing changes:

None

Description of developer facing changes:

None

Description of development approach:

  1. Ran runlint.bat on a clean master checkout. Committed the resulting changes and updated .git-blame-ignore-revs.
  2. Added #!/usr/bin/env python3 shebangs to all scons files so the identify library recognizes them as Python. This makes pre-commit CI cover them going forward (thanks @seanbudd for the suggestion, credit to @SaschaCowley and @michaelDCurran for the idea).
  3. Ran add-trailing-comma and ruff format on the now-recognized scons files and updated .git-blame-ignore-revs.
  4. Excluded scons files from the checkPot and pyright pre-commit hooks. SCons injects globals (Import, Export, env, etc.) at runtime that pyright can't resolve, and scons files don't contain translatable strings.

This PR was developed with AI assistance (Claude Code) with human review and manual testing.

Testing strategy:

Ran runlint.bat, add-trailing-comma, and ruff format again after committing -- no further changes produced. Verified all pre-commit hooks pass locally, including on source/comInterfaces_sconscript (the only scons file under source/).

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

These files were not being recognized as Python by pre-commit CI
on Linux, so they were never auto-formatted.
@christopherpross christopherpross marked this pull request as ready for review April 8, 2026 04:39
@christopherpross christopherpross requested a review from a team as a code owner April 8, 2026 04:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Formats previously-unlinted SCons scripts and a .pyw entrypoint by applying runlint.bat output, and records the formatting commit in .git-blame-ignore-revs to keep git blame useful.

Changes:

  • Applied automated formatting to sconstruct and multiple *sconscript files.
  • Applied automated formatting to source/_bridge/runtimes/synthDriverHost/main.pyw.
  • Added the formatting commit to .git-blame-ignore-revs.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
source/_bridge/runtimes/synthDriverHost/main.pyw Formatting-only changes (blank lines, trailing comma) consistent with lint/format tooling.
sconstruct Formatting-only changes; removed unused imports; reflowed long calls for readability.
nvdaHelper/sonic/sconscript Formatting-only (string quoting).
nvdaHelper/javaAccessBridge/sconscript Formatting-only (wrapped long env.Command call).
nvdaHelper/espeak/sconscript Formatting-only (trailing whitespace cleanup, blank line).
nvdaHelper/archBuild_sconscript Formatting-only (line wrapping, quoting).
.git-blame-ignore-revs Adds the formatting commit hash so blame ignores mass-format changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +393 to +397
lambda target, source, env: (
open(buildVersionFn, "w", encoding="utf-8").write(
"version = {version!r}\n"
"publisher = {publisher!r}\n"
"updateVersionType = {updateVersionType!r}\n"
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this uses open(...).write(...) without an explicit close. Using a context manager (or Path.write_text) would guarantee the handle is closed before later build steps (e.g., cleanup/Delete on Windows) and is clearer to readers.

Copilot uses AI. Check for mistakes.
@christopherpross
Copy link
Copy Markdown
Contributor Author

The comments from Copilot look valid to me, but I think they are out of scope for this PR since these are pre-existing issues, not introduced by the formatting changes. I'll leave them open and let the reviewers decide.

@seanbudd
Copy link
Copy Markdown
Member

seanbudd commented Apr 8, 2026

now that the pre-commit PRs have been merged, can we specify them in pre-commit ci config so these are auto linted?

@christopherpross
Copy link
Copy Markdown
Contributor Author

@seanbudd Do you mean adding a files pattern to the ruff hooks in this PR so pre-commit CI covers the scons files?

I checked and identify (v2.6.18) recognizes SConstruct/SConscript as type scons, so types_or would work for canonical casing. But the files in this repo are lowercase (sconstruct, archBuild_sconscript, etc.), which identify doesn't recognize. So a files pattern seems necessary unless we rename the files.

@seanbudd
Copy link
Copy Markdown
Member

seanbudd commented Apr 8, 2026

I think we should reconsider changing the casing to match scons properly

@christopherpross
Copy link
Copy Markdown
Contributor Author

@seanbudd Agreed, renaming would be cleaner.

I'm not too familiar with SCons yet but would work myself into it. A first search found quite a few references to the current names.

Open question: identify only recognizes exactly SConstruct/SConscript. Prefixed files like archBuild_sconscript aren't recognized even with canonical casing. Not sure what the best approach for those would be.

Should we do the renaming in this PR or use a files pattern for now and open an issue for the renaming?

@seanbudd
Copy link
Copy Markdown
Member

Does adding shebangs e.g. #!/usr/bin/env python3 to the top of the files makes them recognised as python on pre-commit CI?

@christopherpross
Copy link
Copy Markdown
Contributor Author

@seanbudd Ok, that's genius, I wouldn't have thought of that. Yes, it works. I tested it locally: if we add a shebang to the scons files, identify recognizes them as Python. Problem solved. I'd do that in this PR, then pre-commit CI covers the scons files without renaming. Just let me know if that's ok with you.

@seanbudd
Copy link
Copy Markdown
Member

great! please do that and thank @SaschaCowley and @michaelDCurran for the idea 😄

SCons files use magic globals (Import, Export, env, Dir, etc.)
injected at runtime, causing false positives in pyright.
They also don't contain translatable strings, so checkPot
doesn't apply.
@christopherpross christopherpross force-pushed the fix-ruff-format-scons-files branch from 6517857 to b3f4710 Compare April 10, 2026 07:08
@christopherpross
Copy link
Copy Markdown
Contributor Author

@seanbudd Done, added shebangs to all scons files and excluded them from checkPot and pyright since neither applies to scons. Thanks @SaschaCowley and @michaelDCurran for the idea, and thanks for taking the time to review this!

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.

3 participants