hundreds-carpet-28072
06/03/2024, 12:20 PM--filter-files
option similar to https://pycqa.github.io/isort/docs/configuration/options#filter-files that would tell Pants to filter the files it’s being passed. Currently, we need to ensure all files passed to Pants aren’t being ignored and can be handled.wide-midnight-78598
06/03/2024, 1:24 PMhundreds-carpet-28072
06/04/2024, 2:04 PMpre-commit run
will run on changed files between two commit refs. In our pre-commit config we have a hook for pants lint
which pre-commit appends files to when ran e.g. pants lint dir/file1.py main.py
.
The issue we had was that the .github
dir used to be ignored by default by Pants, but pre-commit would still pick up changed files within that dir for markdown formatting, for instance. So this file would be passed to pants from pre-commit like pants lint .github/TEMPLATE.MD
which would result in a Pants glob error as that file “couldn’t be found” since it was being ignored.
Simplest solution here was to just tell Pants to not ignore that dir, which is the default in current Pants version, but that’s beside the point. I could see this being an issue for other scenarios where Pants is passed files (by pre-commit or other). Which is presumably why linters have these --filter-files
options? Thoughts?wide-midnight-78598
06/04/2024, 3:42 PM--changed-since
behavior and call that from pre-commit? pants --changed-since=origin/main lint
kinda thing?hundreds-carpet-28072
06/06/2024, 9:20 AMIs there any way to leverage pant’sYes, that was an alternative option - to pass the from/to refs that pre-commit would use to pants’behavior and call that from pre-commit?--changed-since
kinda thing?pants --changed-since=origin/main lint
—changed-since
option. But it would be nice to not have to duplicate this. I can imagine this feature would be useful for other cases where it’s not as easy to replicate the files that may be being passed to Pants by other tools.