-
Notifications
You must be signed in to change notification settings - Fork 121
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
Excluding files unexpected behavior. #347
Excluding files unexpected behavior. #347
Comments
We need to provide a way to control this behavior. |
I have the same issue, but only when running [files]
extend-exclude = ["src/assets/locales"]
locale files are ignored when running from the terminal, but not from - repo: https://github.com/crate-ci/typos
rev: v1.3.3
hooks:
- id: typos-src
# args:
# - --exclude
# - src/assets/locales #uncommenting args works, but its not reading my config file
|
What about the hook attribute exclude ? It can exclude files with specified pattern. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Hello, when we can expect the fix for the issue? Just a question, not pushing for any actions 😉 |
The core of this is we need a natural mode where we trust the user and a scripted mode where we don't trust the user. The blocker is defining how to express this in the UI. Bonus points for including any precedence from other tools Also want to note that #461 has the workaround of duplicating the exclusions |
Thanks @epage , currently as a workaround we started using |
Additional workaround is:
Got it from here as the same issue exists in interrogate package |
The same issue as in isort fixed by PR 939 and black fixed by PR 1032 Same problem was happening with |
@sshishov thanks for those examples. To summarize:
I wish there was a flag that was common between tools, even if the sample size is just two, as being consistent can be more important than being ideal on its own. Since these aren't consistent, my next thought is on which more clearly communicates intent. I feel like isort's only makes sense when reading the docs and thinking about what it is trying to say. black's makes a little more sense. "force" make it clear this is a binary flag and that it is overriding some default behavior. I lean towards that somewhat even though something still feels off to me. Really, we are implicitly forcing the the args to be respected independent of the exclusions. I just can't think of a succinct way of saying that, so maybe just mirroring black would be best. If people know of other examples, I'm still open open on this. At least for me adding the flag, it might be a week or so as I'm trying to wrap up some major work on the clap crate. |
Here's another example - AFAIK, this behaviour exists because you're expected to run prettier on a folder or multiple files and rarely run it on a single file. That is a pattern I'd like to see in typos as well, but it's up to you. I think it's easier to have 2 configs - one with a blacklist and one without one, than adding multiple cli flags to ignore/force unignore configuration settings. My original issue was with running typos as a github action on changed files, which then spellchecks blacklisted files as well. It would have been possible to filter out the blacklist from the changelist, if the exclude config was in a format bash can parse natively. Of course, I can install toml parsers, filter out the blacklist from the changeset and pass that along to Btw, thanks for closing the issue I opened and redirecting me here. I didn't find this issue initially. |
This would be better placed in `.typos.toml` rather than pre-commit config, but at time of writing, `typos` doesn't honor exclusions for explicitly passed files: crate-ci/typos#347
This would be better placed in `.typos.toml` rather than pre-commit config, but at time of writing, `typos` doesn't honor exclusions for explicitly passed files: crate-ci/typos#347
This would be better placed in `.typos.toml` rather than pre-commit config, but at time of writing, `typos` doesn't honor exclusions for explicitly passed files: crate-ci/typos#347
This is what I'm using. For example: repos:
- repo: https://github.com/crate-ci/typos
rev: v1.13.10
hooks:
- id: typos
exclude: |
(?x)^(
.*\.csv
|.*\.xml
)$ You can also explicitly limit to certain file types by overriding the repos:
- repo: https://github.com/crate-ci/typos
rev: v1.13.10
hooks:
- id: typos
types_or:
- javascript
- python IMO one of the powers of pre-commit is that it already passes the correct filenames, based on hook selection and exclusion, so tools don't have to reimplement undifferentiated inclusion/exclusion features. |
For tools written exclusively for pre-commit, that works well. However, this tool is written more generally and needs to have its own logic. |
This reverts commit fc7f517. This has two problems - This doesn't correctly handle spaces, likely needing crate-ci#708 - This overrides excludes, see crate-ci#347 This also has a weird cost/benefit balance because this requires enough repo history to do the analysis which takes time to pull down. Rather than waiting until the relevant changes are in to make this work, I'm pulling this out for now. Fixes crate-ci#806
Hi @epage. Would you accept a PR adding a new
I really wish I could use On a second thought, the I think by default, we want Since |
Yes, when looking at black before, I thought it was a bool and not yet another exclude type which seems like it'd be awkward to deal with.
Is If we went this route, it'd be a breaking change and we'd need to bump to 2.0. Not the end of the world but something to keep in mind. I also feel like we'd need a way to help the user discover that we ignored what they said and they need to pass in an extra flag. Not thrilled with doing that. Most of this problem seems to be centered on pre-commit-like workflows where we shouldn't be trusting the external source of information. |
I've done more research and compared other tools, and I admit that what I've suggested isn't that common. It depends on people's preferences, but there doesn't seem to be any consensus. Just for example, there is ESLint which displays a warning when excluded files are passed to the command line and requires an explicit However if we take into account the issue regarding backwards compatibility, I agree it's definitely preferable not to change the existing behavior. Apologies for not thinking of that. As a further example, there is also Ruff which implemented I can understand your hesitations to add such a flag, but its primary purpose is to enable I am always willing to open a PR if you wish. |
My concern with |
Closed via #837 |
Current settings:
_typos.toml
.pre-commit-config.yaml
Expected behavior:
JSON files must be excluded
Expected behavior:
All files are checked.
Steps to reproduce
pre-commit run typos --all-files
The text was updated successfully, but these errors were encountered: