-
-
Notifications
You must be signed in to change notification settings - Fork 583
fix(wip): Access .pre-commit-hooks.yaml as artifact
#740
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
Merged
MaxymVlasov
merged 4 commits into
antonbabenko:rewrite_hooks_on_python
from
webknjaz:bugfixes/hooks-cfg-packaging-access
Dec 31, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
51cd1a0
Access `.pre-commit-hooks.yaml` as artifact
webknjaz f5157cd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 38476a3
Merge branch 'rewrite_hooks_on_python' into bugfixes/hooks-cfg-packag…
MaxymVlasov 7403b66
Merge branch 'rewrite_hooks_on_python' into bugfixes/hooks-cfg-packag…
MaxymVlasov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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'm a way too unfamiliar with all this Python magic, though I'm looking into how we can skip the non-obvious step:
Can this be remediated by e.g. symlinking the
/.pre-commit-hooks.yamlinto/pre_commit_terraform/_artifacts/.pre-commit-hooks.yaml?Else we need to either add a GHA to get the command run automatically (and changed pushed to branch) or drop a comment into
/.pre-commit-hooks.yamlfile about a need to run a command once the file is changed. WDYT?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 don't think this is necessary. The GHA bit would be a part of the test infra PR that I didn't get to yet. The local quirk is already mentioned in the readme. And the pre-commit invocations do this under the hood, we don't have any control over it, this is always done.
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.
Also note that this is a PR against a non-master branch.
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.
Symlinking won't work because those are turned into regular files during packaging and aren't preserved outside the repo.
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.
Great. Thanks for details. That all makes sense. Especially the "the pre-commit invocations do this under the hood, we don't have any control over it, this is always done" bit which just discards my inquiry as the automation is kinda there already 👍🏻
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.
Yeah.. To expand on this, basically,
pre-commitusespip installas a method to source the dependencies of your hook. As a side effect, it also installs it as a regular Python package distribution. To install a regular folder or a Git repo this way, a dist should first be built. That dist is a wheel (.whl: https://packaging.python.org/en/latest/glossary/#term-Wheel) — a zip file with your project in it's “built” state; it's essentially aziparchive that gets unpacked intosite-packages/(plus some metadata / deps handling on install).When you what to test your app locally w/o pre-commit, you can reproduce a similar thing via
pip install .and alsopip install pytestwhen you get to usingpytestfor testing. However, during development you usually use editable modepip install -e .which allows changing files in your Git repo without reinstalling (mostly) — it also builds wheels under the hood, but those wheels are special and almost don't contain any payload, short of the metadata and the artifacts. This is one of those artifacts that gets into these wheels and then is copied intosite-packages/.