Skip to content

Fix check_all/fix_all forwarding ruff's "." arg into pyright - #60

Open
benoit74 wants to merge 1 commit into
openzim:mainfrom
benoit74:fix-check-all-pyright-scoping
Open

benoit74 wants to merge 1 commit into
openzim:mainfrom
benoit74:fix-check-all-pyright-scoping

Conversation

@benoit74

Copy link
Copy Markdown
Collaborator

Summary

pyright scopes itself via [tool.pyright] include in pyproject.toml. check_all (and fix_all's sibling call pattern) passes its own args or "." fallback — needed so ruff checks the whole tree when invoked bare via the hatch script — straight through to check_type as well, which forwards it as pyright .. An explicit path argument overrides pyright's include scoping and falls back to exclude-only filtering, so any directory outside include (e.g. a project's own contrib/, scripts/, or similar folder not listed in ["src", "tests", "tasks.py"]) gets type-checked too, and can report spurious errors that have nothing to do with the change under review.

Found this while consuming the template in openzim/youtube (openzim/youtube#483), where it surfaced real false-positive errors on contrib/ and tests-integration/ (both outside include) — but only when going through check_all/fix_all, not when calling check_type directly, which made it a bit of a head-scratcher at first.

Fix

Keep a separate ruff_args variable for the lint/format calls (which do need the . fallback) and leave check_type's own default untouched, so check_all/fix_all behave exactly like calling check_type on its own.

Verification

Reproduced locally against this repo: with a file placed outside include containing a genuine type error, inv check-all incorrectly flagged it before this change, and correctly ignores it after.

Note

I noticed CHANGELOG.md's [Unreleased] section already has a related entry ("Pyright ignores .hatch/**..."), so I added mine alongside it rather than opening a separate discussion about versioning.

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5ed9c35) to head (4b86971).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #60   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines            8         8           
  Branches         1         1           
=========================================
  Hits             8         8           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pyright scopes itself via [tool.pyright] include in pyproject.toml.
check_all passed its own args-or-"." fallback (needed so ruff checks
the whole tree when invoked bare via hatch) straight through to
check_type as well, which forwards it as `pyright .`. An explicit
path argument overrides pyright's include scoping and falls back to
exclude-only filtering, so any directory outside include (e.g. a
project's own contrib/ or scripts/ folder, anything not in
["src", "tests", "tasks.py"]) gets type-checked and can report
spurious errors that have nothing to do with the change under
review.

Found while consuming this template in openzim/youtube, where it
surfaced real false-positive errors on contrib/ and
tests-integration/ (both outside include) only when going through
check_all/fix_all, not when calling check_type directly. Reproduced
and verified the fix here too: a file with a genuine type error
placed outside include is (correctly) ignored by `inv check-all`
after this change, and was (incorrectly) flagged before it.
@benoit74
benoit74 force-pushed the fix-check-all-pyright-scoping branch from 9e9d871 to 4b86971 Compare November 27, 2026 16:10

This branch has not been deployed

No deployments
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