Repository navigation
[ty] Fix --force-exclude for directories with an excluded ancestor - #28451
Conversation
Memory usage reportMemory usage unchanged ✅ |
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 97.84%. The percentage of expected errors that received a diagnostic held steady at 96.45%. The number of fully passing files held steady at 128/145. |
|
--force-exclude for directories with an excluded ancestor
| // The exclusion also applies when the passed directory is inside an excluded directory. | ||
| let output = case | ||
| .command() | ||
| .arg("--force-exclude") | ||
| .arg("out/amd64/install") | ||
| .output()?; | ||
| assert!(output.status.success(), "{output:?}"); | ||
|
|
There was a problem hiding this comment.
lol.
Unfortunately not, but I've been tempted many times to make ty_project behavior mdtestable. The reason I haven't already done so is that ty_test would have to depend on ty_project, which makes incremental compilation time a little slower for typing only changes. However, it would unlock:
- Testing scripts
- Testing fixes
- Testing any project behavior....
|
Codex just found this:
|
|
I'll take a look. This is a little annoying 😆 |
`uv check` passes workspace members to ty as explicit paths, which override configured exclusions. Pass `--force-exclude` when automatically selecting members of a virtual workspace. The rule is to honor user intent over implicit behavior: 1. Plain `uv check` from within an excluded workspace member: *still check that member*. The current directory selects the enclosing project, even when run from a subdirectory. 2. Plain `uv check` at a virtual workspace root: *check only non-excluded members*. This includes respecting exclusions of ancestor directories, e.g. excluding `vendor` also excludes `vendor/some-member`. 3. Plain `uv check` at a workspace root that defines a project: *check the root project*, even if excluded. 4. `uv check --all-packages`: *check all members, including excluded ones*. 5. `uv check --package $excluded_member`: *check the selected member, even if excluded*. 6. `uv check --script script.py`: *check the selected script, even if excluded*. 7. `uv check --no-project`, or outside a project: *leave file discovery and exclusions to ty*. uv passes no target paths. For selected project directories, exclusions still apply to files and subdirectories discovered inside them. uv also continues to exclude nested workspace members that weren't selected. The workspace tests now use ty 0.0.80, which includes the ancestor-exclusion fix in [astral-sh/ruff#28451](astral-sh/ruff#28451). Fixes #21551.
Summary
When
--force-excludeis used with a directory inside an excluded ancestor, ty still checks the directory's files. Check its ancestors before walking it, consistent with how explicitly passed files are handled.Related to astral-sh/uv#21551
Test Plan
Added CLI test