Skip to content

Conversation

@MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Jun 15, 2025

Summary

As discussed, this PR changes the semantics of exclude globs to be anchored. That means, src now only matches <project_root>/src but no longer <project_root>/build/src. Or *.py now only matches python files directly inside the project root but no longer matches any file with a py extension.

The motivation for this change is to make the behavior consistent with incldue where anchoring is desired to allow eagerly skipping over directories that are known not to be included.

Just for reference:

  • This will make ty's exclude handling slightly more incosistento to uv's build backend exclude globs. The two already differed before in that uv anchors no exclude patterns at all whereas, before this PR, ty only anchored paths containing a / (same as gitignore).
  • This deviats from gitignore which only anchors paths that contain a / (a path separator)

Test Plan

Update tests

@MichaReiser MichaReiser added configuration Related to settings and configuration ty Multi-file analysis & type inference labels Jun 15, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 15, 2025

mypy_primer results

No ecosystem changes detected ✅

pub(crate) struct PortableGlobPattern<'a> {
pattern: &'a str,
is_exclude: bool,
kind: PortableGlobKind,
Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I couldn't help myself but this small refactor allows removing a fair chunk of code and makes the API more explicit

@MichaReiser MichaReiser force-pushed the micha/exclude-anchoring branch from 3c6dda7 to 10a78fb Compare June 15, 2025 13:52
@MichaReiser MichaReiser marked this pull request as ready for review June 15, 2025 13:52
@carljm carljm removed their request for review June 17, 2025 01:56
@MichaReiser MichaReiser requested a review from BurntSushi June 17, 2025 06:21
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Nice, this seems nicer to me. :-) Thank you!

Co-authored-by: Andrew Gallant <andrew@astral.sh>
@MichaReiser MichaReiser enabled auto-merge (squash) June 18, 2025 08:52
@MichaReiser MichaReiser merged commit 37fdece into main Jun 18, 2025
34 checks passed
@MichaReiser MichaReiser deleted the micha/exclude-anchoring branch June 18, 2025 08:57
dcreager added a commit that referenced this pull request Jun 19, 2025
* main: (68 commits)
  Unify `OldDiagnostic` and `Message` (#18391)
  [`pylint`] Detect more exotic NaN literals in `PLW0177` (#18630)
  [`flake8-async`] Mark autofix for `ASYNC115` as unsafe if the call expression contains comments (#18753)
  [`flake8-bugbear`] Mark autofix for `B004` as unsafe if the `hasattr` call expr contains comments (#18755)
  Enforce `pytest` import for decorators (#18779)
  [`flake8-comprehension`] Mark autofix for `C420` as unsafe if there's comments inside the dict comprehension (#18768)
  [flake8-async] fix detection for large integer sleep durations in `ASYNC116` rule (#18767)
  Update dependency ruff to v0.12.0 (#18790)
  Update taiki-e/install-action action to v2.53.2 (#18789)
  Add lint rule for calling chmod with non-octal integers (#18541)
  Mark `RET501` fix unsafe if comments are inside (#18780)
  Use `LintContext::report_diagnostic_if_enabled` in `check_tokens` (#18769)
  [UP008]: use `super()`, not `__super__` in error messages (#18743)
  Use Depot Windows runners for `cargo test` (#18754)
  Run ty benchmarks when `ruff_benchmark` changes (#18758)
  Disallow newlines in format specifiers of single quoted f- or t-strings (#18708)
  [ty] Add more benchmarks (#18714)
  [ty] Anchor all exclude patterns (#18685)
  Include changelog reference for other major versions (#18745)
  Use updated pre-commit id (#18718)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Related to settings and configuration ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants