This is inspired by my want to type-check my entire repository with ty whenever prek runs (regardless of what files are actually changed) but not wanting it to include any untracked files I have. This is something that's hard to do with just a hook configuration, as you can see in the 4 comments starting from: astral-sh/ty#269 (comment)
The best I can do is either:
repos:
- repo: local
hooks:
- id: ty-check
name: ty-check
language: system
entry: ty check .
pass_filenames: false
or the python language variant:
repos:
- repo: local
hooks:
- id: ty-check
name: ty-check
language: python
entry: ty check .
pass_filenames: false
args: [--python=.venv/]
additional_dependencies: [ty]
which will both run ty check on all files, including untracked.
It would be better if I could specify some option, maybe all_files: true, to have that hook always run as if it were run as part of prek run --all-files. While I could have a hook with a custom Python script that calls git ls-files, it's certainly more involved than being able to just define this through metadata (and slower due to e.g. Python startup times; also, prek can reuse the generated list for multiple hooks needing this or perhaps even for its own use).
I should note that this would be, to my knowledge, the first new feature for the hook configuration format (.pre-commit-hooks.yaml); from what I understand, so far only the project configuration (prek.toml / .pre-commit-config.yaml) may have extra features in it.
A similar feature was suggested in the pre-commit repo a couple of times in the past, but these suggestions were rejected:
pre-commit/pre-commit#2194
pre-commit/pre-commit#2405
pre-commit/pre-commit#2818
A similar sentiment of not wanting untracked files to affect what the hook does can be seen in other issues:
pre-commit/pre-commit#708
pre-commit/pre-commit#1212
pre-commit/pre-commit#1981
pre-commit/pre-commit#2660 (maybe, the description does not make it clear)
This is inspired by my want to type-check my entire repository with
tywhenever prek runs (regardless of what files are actually changed) but not wanting it to include any untracked files I have. This is something that's hard to do with just a hook configuration, as you can see in the 4 comments starting from: astral-sh/ty#269 (comment)The best I can do is either:
or the
pythonlanguage variant:which will both run
ty checkon all files, including untracked.It would be better if I could specify some option, maybe
all_files: true, to have that hook always run as if it were run as part ofprek run --all-files. While I could have a hook with a custom Python script that callsgit ls-files, it's certainly more involved than being able to just define this through metadata (and slower due to e.g. Python startup times; also, prek can reuse the generated list for multiple hooks needing this or perhaps even for its own use).I should note that this would be, to my knowledge, the first new feature for the hook configuration format (
.pre-commit-hooks.yaml); from what I understand, so far only the project configuration (prek.toml/.pre-commit-config.yaml) may have extra features in it.A similar feature was suggested in the pre-commit repo a couple of times in the past, but these suggestions were rejected:
pre-commit/pre-commit#2194
pre-commit/pre-commit#2405
pre-commit/pre-commit#2818
A similar sentiment of not wanting untracked files to affect what the hook does can be seen in other issues:
pre-commit/pre-commit#708
pre-commit/pre-commit#1212
pre-commit/pre-commit#1981
pre-commit/pre-commit#2660 (maybe, the description does not make it clear)