-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add options to exclude files #238
Conversation
I think
|
fortitude/tests/check.rs
Outdated
@@ -69,7 +69,7 @@ unknown-key = 1 | |||
| | |||
2 | unknown-key = 1 | |||
| ^^^^^^^^^^^ | |||
unknown field `unknown-key`, expected one of `files`, `ignore`, `select`, `extend-select`, `per-file-ignores`, `extend-per-file-ignores`, `line-length`, `file-extensions`, `fix`, `no-fix`, `unsafe-fixes`, `no-unsafe-fixes`, `show-fixes`, `no-show-fixes`, `fix-only`, `no-fix-only`, `output-format`, `preview`, `no-preview`, `progress-bar` | |||
unknown field `unknown-key`, expected one of `files`, `fix`, `no-fix`, `unsafe-fixes`, `no-unsafe-fixes`, `show-fixes`, `no-show-fixes`, `fix-only`, `no-fix-only`, `output-format`, `preview`, `no-preview`, `progress-bar`, `ignore`, `select`, `extend-select`, `per-file-ignores`, `extend-per-file-ignores`, `file-extensions`, `exclude`, `extend-exclude`, `line-length` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is perhaps getting a little long. Looks like ruff suppresses this somehow. Once we start adding individual rule settings, this might just not be helpful.
Should we add some default pub(crate) static EXCLUDE: &[FilePattern] = &[
FilePattern::Builtin(".bzr"),
FilePattern::Builtin(".direnv"),
FilePattern::Builtin(".eggs"),
FilePattern::Builtin(".git"),
FilePattern::Builtin(".git-rewrite"),
FilePattern::Builtin(".hg"),
FilePattern::Builtin(".ipynb_checkpoints"),
FilePattern::Builtin(".mypy_cache"),
FilePattern::Builtin(".nox"),
FilePattern::Builtin(".pants.d"),
FilePattern::Builtin(".pyenv"),
FilePattern::Builtin(".pytest_cache"),
FilePattern::Builtin(".pytype"),
FilePattern::Builtin(".ruff_cache"),
FilePattern::Builtin(".svn"),
FilePattern::Builtin(".tox"),
FilePattern::Builtin(".venv"),
FilePattern::Builtin(".vscode"),
FilePattern::Builtin("__pypackages__"),
FilePattern::Builtin("_build"),
FilePattern::Builtin("buck-out"),
FilePattern::Builtin("dist"),
FilePattern::Builtin("node_modules"),
FilePattern::Builtin("site-packages"),
FilePattern::Builtin("venv"),
]; We probably want at least the version control ones, maybe some of the others too. |
I think it's just a way to put an inclusive filter on the file choices. If you set it to some subset of a project in
Yes, it's probably worth excluding things like |
I've added a list of default exclude directories and tweaked the logic in I think that respecting |
README.md
Outdated
@@ -152,6 +152,36 @@ preview = true | |||
|
|||
Run `fortitude explain` to see which rules are in preview mode. | |||
|
|||
### Excluding Files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead this should be in docs/index.md
?
Actually, looking at ruff, they have some tools for extracting portions of the README.md
into the site docs. We should look at that at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I've moved that section to the docs along with some other things from the README.
README.md
Outdated
Fortitude will automatically ignore files in some directories (`build/`, `.git/`, | ||
`.venv/`, etc.), and this behaviour can be extended using the `--exclude` option. For | ||
example, to ignore all files in the directory `benchmarks/`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, does --exclude
not override the builtins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From playing around with Ruff, apparently not, as it behaves as if the built-ins are a mandatory set of --extend-exclude
instead of --exclude
. If you want it to lint everything in your venv
, you have to manually pass it venv/lib/Python3.10/site-packages
, and setting your own exclude
doesn't change this behaviour.
I haven't played around with include
in a config file, so I'm not sure how that might affect it.
fortitude/tests/check.rs
Outdated
let tempdir = TempDir::new()?; | ||
apply_common_filters!(); | ||
// Expect: | ||
// - Overwrite 'foo.f90' in config file, see 'base.f90' and 'foo.f90' but not 'bar.f90' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowest possible priority, but you meant this?
// - Overwrite 'foo.f90' in config file, see 'base.f90' and 'foo.f90' but not 'bar.f90' | |
// - Override 'foo.f90' in config file, see 'base.f90' and 'foo.f90' but not 'bar.f90' |
Fixes #233
Opened as a draft as I've yet to add tests.
Doesn't add all features suggested in #233:
--respect-gitignore
is a separate issue (Fortitude should respect.gitignore
#231).--include
isn't an option for the Ruff CLI, and we'll need to handle config files separately for that (CLI and config file should be decoupled #235)--force-exclude
would be a small extension to this, and could be added along with the tests.