Repository navigation
feat: make Ruff discovery cwd-aware - #1
Merged
Merged
Conversation
This was referenced Jul 21, 2026
Closed
TomChv
approved these changes
Jul 21, 2026
TomChv
left a comment
Member
There was a problem hiding this comment.
Approved, I fixed dagger/polyfill#2 so just update your polyfill dep and merge the PR.
Polyfill previously selected the first config filename found while walking up, allowing a farther pyproject.toml to shadow a nearer ruff.toml. Pin the merged dagger/polyfill#4 revision so Ruff discovery consistently uses the nearest enclosing project. Keep the distance logic in the shared discovery implementation instead of duplicating it in this adapter. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
feat/cwd-aware-discovery
branch
from
July 21, 2026 21:56
86a19ad to
1747ddc
Compare
Member
Author
|
Pinned the merged I manually re-ran the original filename-order edge case in a disposable Git workspace: Observed
This covers both prior symptoms: the nearer later-filename config wins, and standing at that project does not also return the farther ancestor. Manual traces: above project, at project, two levels below.
|
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.
Context
Ruff currently exposes one automatic
@checkover the constructor'ssourcePath, whose default is the workspace root. In a workspace containing several Python projects, that means the check is not scoped by the caller's current working directory and there is no shared definition of which Ruff projects belong to the invocation.This PR adopts the cwd-aware project-discovery convention from dagger/dagger#13688.
Behavior after this change
projects(ws)delegates discovery topolyfill.findConfigDirsfor:pyproject.toml;ruff.toml;.ruff.toml.The returned paths are relative to the caller cwd. Discovery includes projects at or below the cwd and, for context, the nearest enclosing project as a
..-prefixed path.checkAll(ws)becomes the automatic@check. It runs Ruff only for paths in the caller's cone: the cwd and descendants. A strict ancestor is discoverable but excluded from the automatic check.For example, the checked-in fixture is:
From
work,projectsreturns:checkAllchecksappand does not reach upward into...Scope
@checkfrom the explicit single-sourcecheckmethod; the method itself remains available and unchanged.lint,fix,format, custom containers, and argument forwarding unchanged..venv,site-packages, andnode_modulesfrom discovery.dagger.toml, sodagger checkno longer depends on module inference.Reviewer guide
The production change is intentionally small:
projectsdefines what is discoverable;checkAlldefines what automatic checking may act on;path.hasPrefix("..") == falseis the cone boundary.cwdScopeCheckexercises behavior rather than only asserting path strings. It overlays invalid Python onto the ancestor and verifies the check still passes, then overlays invalid Python ontowork/appand verifies Ruff fails.Reproduce locally
Run the behavioral integration test:
dagger call ruff cwd-scope-checkInspect discovery directly:
Expected output:
Run the complete module checks:
dagger checkAll 5 checks pass against a locally rebuilt engine.
Known polyfill dependency
A deeper mixed-filename lookup still reproduces dagger/polyfill#2. If the caller is below
work/app, polyfill can select the fartherancestor/pyproject.tomlbefore the nearerwork/app/ruff.tomlbecausepyproject.tomlappears first in the filename list.This PR keeps the adapter on the shared discovery API. The distance comparison should be fixed once in polyfill and then consumed here by updating the pin.