Skip to content

[ty] Escape glob characters in anchored directory paths - #28518

Merged
MichaReiser merged 2 commits into
mainfrom
micha/ty-escape-glob-cwd
Sep 14, 2026
Merged

MichaReiser merged 2 commits into
mainfrom
micha/ty-escape-glob-cwd

Conversation

@MichaReiser

Copy link
Copy Markdown
Member

Summary

Directory names containing glob syntax can change the meaning of anchored include and exclude patterns. Escape the directory components while preserving the user's glob and literal file selection.

Test Plan

Testing: Added regression coverage; ty_project tests, Clippy, and repository hooks pass.

@MichaReiser MichaReiser added the ty The ty type checker label Sep 11, 2026
@astral-sh-bot

astral-sh-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The 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.

@astral-sh-bot

astral-sh-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

@MichaReiser MichaReiser added bug An issue describing something that isn't working, or a PR that fixes a bug configuration Related to settings and configuration of Ruff or ty labels Sep 11, 2026
@MichaReiser
MichaReiser marked this pull request as ready for review September 11, 2026 11:40
@MichaReiser
MichaReiser requested a review from a team as a code owner September 11, 2026 11:40
@astral-sh-bot
astral-sh-bot Bot requested a review from carljm September 11, 2026 11:40
.unwrap();
let filter = builder.build().unwrap();

assert_eq!(filter.match_file("/root/dir[1]/file"), MatchFile::Literal);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we cover this through project file discovery as well? For a project rooted at dir[1] with src.include = ["src/*.py"] and src.exclude = ["src/skip.py"], I’d expect src/keep.py to be indexed and src/skip.py to be skipped. This test checks match_file, but the walker also uses the separate match_directory DFA to decide whether to enter the directory, and exclusions use another matcher. A file-set assertion would protect the full path affected by the escaped root.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can add a separate CLI test. But I think this test is useful on its own. It tests that we use the literal fast-path even if the base path contains escaped characters.

@MichaReiser
MichaReiser requested a review from a team as a code owner September 14, 2026 11:49
@MichaReiser
MichaReiser enabled auto-merge (squash) September 14, 2026 11:50
@MichaReiser
MichaReiser merged commit a65f3d6 into main Sep 14, 2026
71 checks passed
@MichaReiser
MichaReiser deleted the micha/ty-escape-glob-cwd branch September 14, 2026 11:54
@codspeed

codspeed Bot commented Sep 14, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.47%

⚡ 1 improved benchmark
✅ 144 untouched benchmarks
⏩ 60 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ WallTime auto_imports[regular-package/after-module-create] 26.1 ms 25 ms +4.47%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing micha/ty-escape-glob-cwd (4994b52) with main (15f3fe6)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

carljm added a commit that referenced this pull request Sep 14, 2026
…aliases

* origin/main: (21 commits)
  [ty] Share attribute write compatibility checks (#28555)
  [ty] Prefer `ty.toml` and `pyproject.toml` over playground `ty.json` (#28449)
  [`ruff`, `flake8-use-pathlib`] Support `parent_mode` (`RUF064`, `PTH103`) (#28528)
  [`pyupgrade`] Make the fix for `UP040` always unsafe (#28526)
  [`pyupgrade`] Skip `TypeVarTuple` and `ParamSpec` conversions with bounds or constraints (`UP040`, `UP046`, `UP047`) (#28505)
  [ty] Escape glob characters in anchored directory paths (#28518)
  [ty] Handle gradual metaclass ancestry and conflicts (#28474)
  [ty] Preserve recursive metadata in union transformations (#28497)
  [ty] Refactor "desperate" import resolution to use candidate operations that will also apply to module enumeration. (#28543)
  [ty] Report override conflicts introduced by new bases (#28530)
  [ty] Resolve dependencies within correlated inference alternatives (#28252)
  [ty] Extract shared abstract-method analysis (#28537)
  [ty] Reject reassignment of enum members (#28462)
  [ty] Preserve runtime comparison semantics when narrowing tagged unions (#28053)
  [ty] Extract a method on `NameResolver` to advance resolution by single module name component. (#28540)
  [ty] Return root discovery to `NameResolver`, but retain necessary interface changes (#28536)
  [ty] Default-specialize class objects in meta-protocol checks (#28265)
  [ty] Extract module root discovery from `NameResolver`. (#28531)
  [ty] Fix MRO ordering for generic bases (#28172)
  [ty] Run benchmarks for auto-imports in CI (#28490)
  ...

# Conflicts:
#	crates/ty_python_semantic/src/types/narrow.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug configuration Related to settings and configuration of Ruff or ty ty The ty type checker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants