-
-
Notifications
You must be signed in to change notification settings - Fork 830
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
OR
relationship with types
#607
Comments
I don't want to invent a meta-language for this -- it'll be confusing, complicated, and doesn't sound like something I want to maintain. Here's an idea I've been thinking of: Add a This wouldn't enable all potential combinations that you could think up (stuff like |
@asottile Thinking of #744 and based on that implementation of what I thought the desired behavior was... I think having a separate key for Unless we took the following approach:
That could work too. I'll mull on it. If I have the time and inclination I'll put up a proposal and a viable solution :). |
alternative suggestion for config: types:
- [ type1A, type1B, type1C]
- [ type2A, type2B ] in programming terms: make types optional a two-dimensional array type must match (type1A and type1B and type1C) or (type2A and type2B) |
That adds a level of complexity I don't really want:
|
Why would it be incompatible? types: [file, java] # to use for usual cases, would still work
types:
- [file, java]
- [file, css]
- [symlink, python]
# above only used for special cases Well, the current files/types/... is already not obvious for everybody, as #706 shows |
Existing versions of pre-commit would error on list-of-lists
They are at least documented and consistent (everything today is |
I ran into this same issue today with the eslint hook and went down the "why is this not working as an OR?" rabbit hole before busting out ipdb, reading the source, and finding this issue. eslint is currently adding support for Typescript files in addition to JavaScript. I ended up using a similar hack: types: [file]
files: \.(js|ts)$ (I actually had just the second line in my file for a while, but it wasn't working, before I dug in more and learned about I'm happy to keep this locally in my repo, but had some other ideas:
|
Did you ever find out how to solve this? I can't get my eslint hook to pick up .ts or .tsx files. |
@Buuntu did you also add the eslint
|
just a data point for this being useful - this bit me today, spent a few cycles tryna work out what was going wrong (thanks @chriskuehl for pointing me right!) |
Hi @asottile - would you still be open to supporting this? I could try submitting a PR if so EDITHaven't got round to this yet, but it's still on my to-do list |
yeah nobody has stepped up with a better proposal or opposition |
Note, https://github.com/actions/labeler does this by allowing Edit: Looks like syntax is decided? Too bad, I feel it's not ideal. I think if, for example, the black hook changed to: - id: black
types_or: [python, pyi] Then a user adding |
I think you're misunderstanding:
well obviously, you can't add new features and have them work in older versions? but fortunately there's |
But I thought the argument against
I don't think so, if you have |
no the argument against that was because it's schema incompatible and sure, the override of |
To simply provide a custom file on an arbitrary hook, you currently need: - id: any_hook
types: [file]
files: "..." And after this, you will instead need: - id: any_hook
types: [file]
types_or: [file]
files: "..." That is, unless you look up the definition of the hook and/or are sure it won't change, you have to override both now. This is not end-of-the-world, but doesn't seem ideal. I'm not really suggesting a better alternative, either, just pointing out an issue. |
And changing from - id: any_hook
types: [file]
files: "(.py|.pyi|.py.in)$" (and suddenly stopping to test a set of previously checked file often is very hard to detect). |
no you wouldn't need
only if they weren't part of |
So if black (for example), defined
You can be doing anything in your own repo, you know what files you have. In the upstream hook, hopefully not! That was just an example, but one of the usages of
|
Since pre-commit 2.9.0 (2020-11-21), the types_or key can be used to match multiple disparate file types. For more upstream details, see: pre-commit/pre-commit#607 Add the minimum_pre_commit_version to require pre-commit 2.9.0+. Fixes #402
Since pre-commit 2.9.0 (2020-11-21), the types_or key can be used to match multiple disparate file types. For more upstream details, see: pre-commit/pre-commit#607 Add the minimum_pre_commit_version to require pre-commit 2.9.0+. Fixes psf#402
…e-config [pre-commit.ci] pre-commit autoupdate
When we introduced this feature, I had some specific usecases in mind which required an
AND
relationship withtypes
-- it comes to mind that some tools would like to use anOR
relationship, but there isn't a great way to implement this without reverting tofiles
(and thus losing the benefits oftypes
altogether!).This issue is to track some sort of way of enabling an
OR
relationship.This was originally inspired by prettier/prettier#2745
The text was updated successfully, but these errors were encountered: