Repository navigation
[ty] Escape glob characters in anchored directory paths - #28518
Conversation
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. |
Memory usage reportMemory usage unchanged ✅ |
|
| .unwrap(); | ||
| let filter = builder.build().unwrap(); | ||
|
|
||
| assert_eq!(filter.match_file("/root/dir[1]/file"), MatchFile::Literal); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Merging this PR will improve performance by 4.47%
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
…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
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.