Repository navigation
CI: Correct ruff scope and add basedpyright pre-commit hook - #301
Merged
keanjapesan merged 3 commits intoAug 17, 2026
Merged
keanjapesan merged 3 commits into
keanjapesan merged 3 commits into
Conversation
The ruff and ruff-format hooks filtered files through "^(scripts|tests|custom_components)/.+\.py$", a pattern inherited from a Home Assistant configuration. This repository has no custom_components directory and no Python under scripts, and its package source lives under src/, so the filter silently excluded the whole package: only tests/ was ever linted or formatted. Drop the filter so ruff and ruff-format apply to every Python file in the repository. The package source already conforms, so this needs no source changes. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
ModeSevenIndustrialSolutions
requested review from
a team
and
a balanced review from Copilot
August 17, 2026 07:32
There was a problem hiding this comment.
Pull request overview
Updates linting coverage and adds basedpyright validation.
Changes:
- Expands Ruff checks to all Python files.
- Adds the pinned basedpyright pre-commit hook.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hatch-vcs generates src/tag_validate/_version.py at build time, so it is absent from a plain source checkout such as the isolated environment a pre-commit type-checker hook runs in. basedpyright could not resolve "from tag_validate._version import __version__" there and, in turn, flagged "from . import __version__" in the CLI modules that re-export it. Move the runtime import into an else branch and declare __version__ under TYPE_CHECKING, so static analysis resolves the symbol without the generated module present. Runtime behaviour is unchanged: the try/importlib.metadata fallback still runs. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
ModeSevenIndustrialSolutions
force-pushed
the
chore/linting-standardization
branch
from
August 17, 2026 07:42
680a621 to
1a9482a
Compare
The canonical linting setup in lfreleng-actions/actions-template runs the basedpyright type-checker as a pre-commit hook. This repository already carries a [tool.basedpyright] configuration block (typeCheckingMode = "standard") but never wired up the hook, so the type-checker only ran in editors, not in the gate. Add the hook from the DetachHead/basedpyright-prek-mirror, pinned to 1.39.9 to match the canonical reference, inserted without disturbing the repo's own customizations (mypy additional_dependencies, write-good/codespell excludes and args, the skip list). Skip the hook on pre-commit.ci. The mirror bundles a Node runtime, so its hook environment is ~246MiB before any project dependencies, and the runtime imports needed for type resolution push it past the 250MiB tier limit. The hook still runs for local developers via prek/ pre-commit, where the project .venv resolves imports, so this follows the existing pattern of skipping sandbox-incompatible hooks such as gha-workflow-linter. Closes: lfreleng-actions#258 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
ModeSevenIndustrialSolutions
force-pushed
the
chore/linting-standardization
branch
from
August 17, 2026 07:51
1a9482a to
c4b8b85
Compare
5 tasks
keanjapesan
approved these changes
Aug 17, 2026
zxiiro
approved these changes
Aug 17, 2026
zxiiro
left a comment
Contributor
There was a problem hiding this comment.
🤖 Auto-approved by agent: reviewed workflow/code change for security and CI/CD impact, found low risk. Corrects an overly-narrow ruff file scope, adds a basedpyright pre-commit hook (skipped on pre-commit.ci due to a documented size-tier limit, still runs locally), and makes the version import resolve correctly under static type-checking. No security or CI-pipeline impact.
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.
Summary
A generalised linting-configuration update that standardises this
repository's pre-commit setup against the canonical
lfreleng-actions/actions-templatereference. Three focused commits.1. Correct the ruff hook scope (remove a Home Assistant artefact)
The
ruffandruff-formathooks filtered files through^(scripts|tests|custom_components)/.+\.py$— a pattern inherited from aHome Assistant configuration. This repository has no
custom_components/directory, no Python under
scripts/(only shell scripts), and itspackage source under
src/. So the filter silently excluded the wholepackage from ruff — only
tests/was ever linted or formatted in thegate. Dropping the filter lets ruff and ruff-format apply to all Python.
The package source already conforms, so no source changes were required.
2. Guard the generated
_versionimport for type-checkerssrc/tag_validate/_version.pyis generated by hatch-vcs at build timeand is absent from a plain source checkout. The runtime import is now
moved into an
elsebranch with__version__declared underTYPE_CHECKING, so static analysis resolves the symbol without thegenerated module. Runtime behaviour is unchanged (the
importlib.metadatafallback still runs).3. Add the basedpyright pre-commit hook (Closes #258)
Added the hook from
DetachHead/basedpyright-prek-mirror, pinned to1.39.9, inserted without disturbing the repo's own customizations (mypyadditional_dependencies, write-good/codespell excludes and args, theskip:list).basedpyright is skipped on pre-commit.ci. The mirror bundles a Node
runtime, so its hook environment is ~246 MiB on its own — only ~4 MiB
under pre-commit.ci's 250 MiB tier limit. Installing the project's
dependencies via
additional_dependencies(needed to resolve imports inthe sandbox's clean,
.venv-less environment) pushed the build to300.1 MiB and it was rejected. Since there is no room for the imports in
that environment, the hook is added to the
ci.skiplist — the samepattern already used for
gha-workflow-linter. It still runs for localdevelopers via
prek/pre-commit, where the project.venvprovidesimport resolution.
Validation
prek run --all-files— all hooks pass (basedpyright runs locally; theci.skipentry only affects pre-commit.ci).prek run basedpyright --all-files→ 0 errors.Acceptance criteria (#258)
basedpyrighthook added, preserving existing configprek run basedpyright --all-filesreports 0 errorsCloses #258