Repository navigation
Preparatory work & clean-up for #219 - #223
Conversation
|
I like the idea. I wonder if we can simplify this further and reuse existing logic by making local-hooks slightly less special to configure:
I also like the cleanup work that was done for 👍 |
|
Agreed, I'll split it in two commits. Your solution sounds good, but it would make the I'm ok to move to this solution, but don't you think the current JSON schemas definition kind of overlap ? There is some code duplication for the allowed overrides, I'll try to make it more DRY. |
|
Yeah the json schemas do kind of overlap. I really hope to get rid of them eventually (as we've discussed in the other issue) and replace them with a bunch of functions. imo aim for correctness and readability instead of working hard at DRY, I've found that in a lot of cases expressiveness / correctness kind of work against DRY-ness. Though I think replacing the jsonchemas will actually make a lot of things cleaner / more flexible but that's definitely out of scope for this change I would think :) I'm cool with making sha optional as long as we require it in the normal case |
|
A comment on something you wrote "The code already allows overriding of all the keys presented in the backing configuration so the rest would just work" : actually the hooks definition in the manifest & config schemas differ quite a bit : some fields actually cannot be overridden, only With possibly more tweaking (like adding the |
4a3efb9 to
d2691be
Compare
|
I updated the pull request to only contains preliminary changes. Also you wrote "I really hope to get rid of [JSON schemas] eventually, as we've discussed in the other issue". I don't think you mentioned that before in an issue I was part of. Are you refering to issue #157 or something else ? |
|
I'll comment on the second thing when I'm not on the phone :D The first however: though the fields are not specified in the config schema, the way the runtime hook dictionary is made is by merging the config dict on top of the manifest dict. JSON schema is a bit permissive in that it let's you add keys even if they aren't in the schema. |
There was a problem hiding this comment.
Are the changes to this file necessary? I don't see them used elsewhere
There was a problem hiding this comment.
Ok, I'll remove them from this commit
|
Address comment for pre_commit/runner.py and I'll merge 👍 |
|
Ah yeah as for jsonschema, I totally got you confused with another person. I'm terrible sorry about that >.< Here's the comment I mentioned it in: #157 (comment) |
Are you refering to the following code snippet ? Then ok, but we won't be able to reuse that code for the local hooks, as it's nested in the |
clientlib/validate_config.py: moving "sha" field requirement out of JSON schema commands/run.py: code simplification runner.py: made .config a cached_property
Preparatory work & clean-up for #219
|
Oh forgot to mention, please PR to add your name on http://github.com/pre-commit/pre-commit.github.io :D Thanks for contributing! |
This is an attempt to address #219.
As it is a first draft, it misses some tests and a bit of code cleaning, but I'd like an initial design review before fixing the final glitches.
Example of valid _ .pre-commit-config.yaml_ using this feature :
Pros / Cons of the solution choosed:
_run_hook/_run_hookscode duplicationhooks_and_invokerslist of tuples is not entirely satisfying. Maybe it'd be worth having a properHookclass ?