ty icon indicating copy to clipboard operation
ty copied to clipboard

Add `--force-exclude` option to CLI

Open MichaReiser opened this issue 2 months ago • 2 comments

ty checks every path specified on the CLI even if they match an exclude pattern. This is because explicitly passed paths are considered explicit than an exclusion pattern.

This behavior generally matches expectation but it's problematic when integrating ty with other tools that aren't aware of the exclusions. For example, pre-commit (also see https://github.com/astral-sh/ty/issues/269), passes all changed files to ty, including paths excluded in ty.

We should add an option similar to Ruff's --force-exclude that gives exclude patterns higher precedence over the paths passed on the CLI, enforcing that the exclusion rules are respected even for files passed on the CLI

MichaReiser avatar Nov 03 '25 12:11 MichaReiser

Bazel is another example of a tool that typically passes files as individual paths, and therefore would benefit from this feature.

Thank you for all the incredible work!

jimmyt857 avatar Dec 18 '25 16:12 jimmyt857

Good to know. This should be very easy to implement.

MichaReiser avatar Dec 18 '25 17:12 MichaReiser