Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
`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 casesWell, 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
|
When we introduced this feature, I had some specific usecases in mind which required an
ANDrelationship withtypes-- it comes to mind that some tools would like to use anORrelationship, but there isn't a great way to implement this without reverting tofiles(and thus losing the benefits oftypesaltogether!).This issue is to track some sort of way of enabling an
ORrelationship.This was originally inspired by prettier/prettier#2745