Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for excluding files #365

Open
slafs opened this issue Jul 24, 2023 · 2 comments
Open

Option for excluding files #365

slafs opened this issue Jul 24, 2023 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@slafs
Copy link

slafs commented Jul 24, 2023

Hello! First of all, congrats on the v2 release. Really excited about the project!

Is there currently any way to exclude certain files from being processed?
We have a bunch of auto-generated Alembic migration files,
that we have no intention of fixing/linting.

The closest I saw to this feature is #354,
but I wouldn't want to edit those files in any way
(i.e. add a marker on top).

Instead I'd prefer to pass a glob string as an option
(either in CLI or in config file -
e.g. --exclude '**/alembic/versions/**')
to either lint or fix commands.

@amyreese amyreese added the enhancement New feature or request label Jul 24, 2023
@amyreese amyreese added this to the 2.x milestone Jul 24, 2023
@amyreese
Copy link
Member

As a CLI flag, this is simple: we can pass an exclude kwarg to trailrunner.walk(...) to apply excludes when walking. This would be a relatively straightforward PR adding an appropriate exclude_paths value to the Options dataclass and then passing that to trailrunner.

Providing this from a config file will be a bit more tricky, since we would need to materialize configs for each candidate path before we can exclude them, and that normally only happens in fixit_file after we already have spawned child processes. It might be useful instead to move towards materializing configs in fixit_paths based on the parent directory, use that when walking to exclude paths, and then pass those configs through to fixit_file.

This would also have the benefit of frontloading disk access, allow more caching of config objects, and give us access to the materialized set of lint rules for each file in the main process, which would enable work for #321 to preform warmup before spawning child processes.

@datur
Copy link
Contributor

datur commented Aug 15, 2023

It would also be really cool if the linter could skip over a file if there are no rules enable for a given file. Currently it seems all files are visited regardless of if a rule is enabled or not!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants