Skip to content

Sync upstream AddonTemplate#9

Merged
cary-rowen merged 121 commits into
mainfrom
template-sync/addon-template
Apr 30, 2026
Merged

Sync upstream AddonTemplate#9
cary-rowen merged 121 commits into
mainfrom
template-sync/addon-template

Conversation

@cary-rowen

Copy link
Copy Markdown
Contributor

Sync upstream nvaccess/AddonTemplate into WithSounds while preserving add-on metadata and documentation. Keeps Pyright configured but skipped in CI for this template sync.

josephsl and others added 30 commits March 12, 2025 21:53
By default, Pyright rules will be reported and add-on authors can add bad rules with explanations to bad rules list in the end. For examples, see Emoticons and StationPlaylist add-ons.
  Replaced os.path with pathlib.Path.
  buildVars.excludedFiles are now checked with Path.match, which means that patterns are supported, not just specific paths.
  The issue with the difference between \ and / is now fixed.
Fixes file exclusions from the .nvda-addon file specified in buildVars.excludedFiles
  Replaced os.path with pathlib.Path to simplify the code and make it easier to understand.
  The code has been slightly formatted for easier reading.
  - Add typehints
  - Replace os.path in pathlib.Path
  Rename the function to matchesNoPatterns
  Add typehints to input args.
  Use Key in raises messages
  The argument `patterns` can be any iterable, not only `list`
  Use `generator expression` instead of `list comprehension`
  - env.Glob has been replaced with Path.glob, as this allows patterns
    such as `dir/**/*.py` or `**.py` to be used, rather than just `dir/*/*/*.py`.
  - Also added type hints for arguments and return value.
  - Add addonDir & localeDir constants
  - Most os.path has been replaced with pathlib where it seems appropriate
  - Defined docsDir constant
  - Rewrote iteration over addon/doc/*/*.md files
  Now the function accepts the path directly to the documentation directory.
  - Added hints for global variables langDirs and moByLang.
  - The return value of the expandGlobs function is typed.
  Vars:
  - pythonSources
  - i18nSources
  - excludedFiles
  - baseLanguage
  - markdownExtensions
  Added Builder & Copy to list of imports from SCons.Script
  Input arguments & return value type hints for functions:
  - addonGenerator
  - manifestGenerator
  - translatedManifestGenerator
  - generateManifest
  - generateTranslatedManifest
dependabot Bot and others added 27 commits October 27, 2025 18:28
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…ons/download-artifact-6

Bump actions/download-artifact from 5 to 6
…ons/upload-artifact-5

Bump actions/upload-artifact from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This pull request introduces a new pyproject.toml configuration for the addonTemplate project, establishing modern Python project metadata, build settings, and development dependencies. It also updates and refines linting and static analysis configurations to improve code quality and development workflow.
    Fix ruff in pyproject
    Fix pyproject excluding siteScons from pyright
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v7...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the uv group with 3 updates in the / directory: [filelock](https://github.com/tox-dev/py-filelock), [urllib3](https://github.com/urllib3/urllib3) and [virtualenv](https://github.com/pypa/virtualenv).


Updates `filelock` from 3.20.1 to 3.20.3
- [Release notes](https://github.com/tox-dev/py-filelock/releases)
- [Changelog](https://github.com/tox-dev/filelock/blob/main/docs/changelog.rst)
- [Commits](tox-dev/filelock@3.20.1...3.20.3)

Updates `urllib3` from 2.6.2 to 2.6.3
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.6.2...2.6.3)

Updates `virtualenv` from 20.35.4 to 20.36.1
- [Release notes](https://github.com/pypa/virtualenv/releases)
- [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst)
- [Commits](pypa/virtualenv@20.35.4...20.36.1)

---
updated-dependencies:
- dependency-name: filelock
  dependency-version: 3.20.3
  dependency-type: indirect
  dependency-group: uv
- dependency-name: urllib3
  dependency-version: 2.6.3
  dependency-type: indirect
  dependency-group: uv
- dependency-name: virtualenv
  dependency-version: 20.36.1
  dependency-type: indirect
  dependency-group: uv
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ries (NVDA 2026.2) (#19)

Closes #15

This pull request add support for building custom speech pronunciation dictionaries via the add-on template. Changes made:

    Adds "speechDictionraies" sectoin to buildVars
    Adds speech dictionaries manifest key type and generation rules (borrowing custom symbol dictionaries)
Currently, checks are run with GitHub Actions regardless of files which have been changed.

This PR makes checks to be run just for add-ons. Additionally, Python and dependencies are installed using uv and pyproject.toml.
Co-authored-by: Cyrille Bougot <cyrille.bougot@laposte.net>
Various CI fixes and improvements:

    Do not try to build / make release if the workflow is run from this add-on template repo, since it fails and the template is not meant to be used as a release. Fixes: Do not restrict workflow triggers to addon path #22 (comment).
    Modernized uv usage with "uv sync", fixing the failure on previously used "uv pip install". Discussed in Do not restrict workflow triggers to addon path #22 (comment).
    Use uv for each command using Python so that the correct environment is used
    Added .egg-info to .git-ignore
    Updated readme
…y (#25)

Bumps the uv group with 1 update in the / directory: [requests](https://github.com/psf/requests).


Updates `requests` from 2.32.5 to 2.33.0
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v2.32.5...v2.33.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.33.0
  dependency-type: direct:production
  dependency-group: uv
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the uv group with 1 update in the / directory: [uv](https://github.com/astral-sh/uv).


Updates `uv` from 0.9.11 to 0.11.6
- [Release notes](https://github.com/astral-sh/uv/releases)
- [Changelog](https://github.com/astral-sh/uv/blob/main/CHANGELOG.md)
- [Commits](astral-sh/uv@0.9.11...0.11.6)

---
updated-dependencies:
- dependency-name: uv
  dependency-version: 0.11.6
  dependency-type: direct:production
  dependency-group: uv
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2 to 3.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](softprops/action-gh-release@v2...v3)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the uv group with 1 update in the / directory: [lxml](https://github.com/lxml/lxml).


Updates `lxml` from 6.0.2 to 6.1.0
- [Release notes](https://github.com/lxml/lxml/releases)
- [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
- [Commits](lxml/lxml@lxml-6.0.2...lxml-6.1.0)

---
updated-dependencies:
- dependency-name: lxml
  dependency-version: 6.1.0
  dependency-type: direct:production
  dependency-group: uv
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@cary-rowen cary-rowen merged commit 8de6ffa into main Apr 30, 2026
4 checks passed
@cary-rowen cary-rowen deleted the template-sync/addon-template branch April 30, 2026 00:39

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request significantly refactors the build system and project configuration. Key changes include the introduction of a modular SCons tool (NVDATool) to handle addon packaging, manifest generation, and documentation building, replacing inline logic in sconstruct. It also adds a comprehensive pre-commit configuration, updates project metadata and dependencies in pyproject.toml, and introduces type hinting in buildVars.py. Review feedback highlighted critical typos in SCons builder definitions, incorrect default value types for markdown extensions, and potential runtime errors due to missing null checks when handling translation files.

env["BUILDERS"]["NVDAManifest"] = Builder(
action=manifestAction,
suffix=".ini",
src_siffix=".ini.tpl",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

There is a typo in the parameter name src_siffix. It should be src_suffix for the SCons Builder to correctly identify source files by their extension.

Suggested change
src_siffix=".ini.tpl",
src_suffix=".ini.tpl",

env["BUILDERS"]["NVDATranslatedManifest"] = Builder(
action=translatedManifestAction,
suffix=".ini",
src_siffix=".ini.tpl",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

There is a typo in the parameter name src_siffix. It should be src_suffix.

Suggested change
src_siffix=".ini.tpl",
src_suffix=".ini.tpl",

src_siffix=".ini.tpl",
)

env.SetDefault(mdExtensions={})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

mdExtensions should be initialized to an empty list [] rather than an empty dictionary {}. The markdown library expects an iterable (such as a list) for the extensions parameter, and passing a dictionary will cause a TypeError or unexpected behavior during the build process.

Suggested change
env.SetDefault(mdExtensions={})
env.SetDefault(mdExtensions=[])

Comment on lines +24 to +30
try:
with moFile.open("rb") as f:
_ = gettext.GNUTranslations(f).gettext
except Exception:
summary = addon_info["addon_summary"]
else:
summary = _(addon_info["addon_summary"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The code attempts to call .open() on moFile without checking if it is None. Since moFile is an optional parameter and can be None (e.g., for the base language or missing translations), it should be checked explicitly to avoid relying on exception handling for expected logic flow.

Suggested change
try:
with moFile.open("rb") as f:
_ = gettext.GNUTranslations(f).gettext
except Exception:
summary = addon_info["addon_summary"]
else:
summary = _(addon_info["addon_summary"])
summary = addon_info["addon_summary"]
if moFile is not None:
try:
with moFile.open("rb") as f:
_ = gettext.GNUTranslations(f).gettext
summary = _(addon_info["addon_summary"])
except Exception:
pass

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.

6 participants