-
Notifications
You must be signed in to change notification settings - Fork 7
ENH: Cache schemas for taplo lint #29
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
base: main
Are you sure you want to change the base?
Conversation
taplo lint supports the --cache-path argument to cache downloaded schemas. This adds the parameter if not passed already, using a directory in the activated venv.
redeboer
left a comment
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.
Looks good, but I have to check if it all works as expected. Some small comments below
| name: taplo-lint | ||
| description: Lint TOML documents | ||
| entry: taplo lint | ||
| entry: cached-taplo-lint |
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 better to have a separate hook? I don't want to temper with the default behaviour of taplo-lint.
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.
I understand your concern, but I'd still "shadow" the original hook:
- I suspect that most users just install the hook and forget, no fancy setup, no weird customizations, no reading docs when updating => having it "magically go faster" after a
pre-commit autoupdateseems the best we can do. - Those who added
--cache-path somethingshouldn't be impacted, since the wrapper takes this case into account (and does nothing when it's the case).
Sure things could break in other ways:
taplo lintchanging the caching behavior- some Murphy laws 🤷
Of course you have the last word.
cached_taplo_lint.py
Outdated
| args = sys.argv[1:] | ||
|
|
||
| if '--cache-path' not in args: | ||
| cache_path.mkdir(parents=True, exist_ok=True) | ||
| args.extend(['--cache-path', str(cache_path)]) |
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.
I'd work with ArgumentParser here.
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.
I tried a little but I'm not really getting it.
ArgumentParser main goal seems to be checking and preparing arguments passed to the script to be used by itself. In this case, we need to construct arguments to be passed to another command, while very much not parsing anything else (taplo does that by itself already - and we're not re-implementing it all, right? 🤔)
Could you give me an example on what you are thinking about?
serl
left a comment
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.
Thanks for the very fast review!
(I added some simple tests to the wrapper in the meantime, just to be sure that it behaves)
| name: taplo-lint | ||
| description: Lint TOML documents | ||
| entry: taplo lint | ||
| entry: cached-taplo-lint |
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.
I understand your concern, but I'd still "shadow" the original hook:
- I suspect that most users just install the hook and forget, no fancy setup, no weird customizations, no reading docs when updating => having it "magically go faster" after a
pre-commit autoupdateseems the best we can do. - Those who added
--cache-path somethingshouldn't be impacted, since the wrapper takes this case into account (and does nothing when it's the case).
Sure things could break in other ways:
taplo lintchanging the caching behavior- some Murphy laws 🤷
Of course you have the last word.
cached_taplo_lint.py
Outdated
| args = sys.argv[1:] | ||
|
|
||
| if '--cache-path' not in args: | ||
| cache_path.mkdir(parents=True, exist_ok=True) | ||
| args.extend(['--cache-path', str(cache_path)]) |
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.
I tried a little but I'm not really getting it.
ArgumentParser main goal seems to be checking and preparing arguments passed to the script to be used by itself. In this case, we need to construct arguments to be passed to another command, while very much not parsing anything else (taplo does that by itself already - and we're not re-implementing it all, right? 🤔)
Could you give me an example on what you are thinking about?
Closes #28
taplo lint supports the --cache-path argument to cache downloaded schemas. This adds the parameter if not passed already, using a directory in the activated venv.