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
(Feature Request) Mandatory hooks / less graceful ImportError failure #25
Comments
Hi, thanks for using autohooks :-) If I understand you correctly I already did work on this problem in #24 |
Ah it looks like your approach was a bit different to my idea: modify the shebang to make it work from outside, rather than modify the error to make it fail... Certainly cooler if we can get it working! I see a couple of potential roadblocks/opportunities though: 1. Cross-platform limitations of shebang 2. 3. Poetry is easy, but the rest..? 4. There's still a use case for fail on And a quick Q: Sorry for my ignorance of |
Thanks for the pointer. Wasn't aware of this issue. But IMHO it can be fixed with the /usr/bin/env -S pipenv shell python3 works for me. |
I've dropped my usage of python 2 completely therefore python is python 3 for me always. Of course that's not true for all people yet and |
Personally I would add a poetry mode only and only add the flexibility for other tools on demand. Mode.MANUAL currently means you have to put autohooks into your python path manually e.g. by activating your environment. I didn't found a better name for that mode yet ;-)
When I started to write autohooks I wasn't aware of this git switch and didn't wanted to always fail if the dependencies aren't installed. But now I think this approach wasn't a good decision and shouldn't be the default anymore. Therefore I've started to work on #24
Yes you are right. I really think not failing if the dependencies aren't available should only be an option anymore and not the default. This needs to be changed in the next major release. But to fix this situation I wanted to get a sane way to run autohooks without having to care about activating an environment before. |
@alex-thewsey-ibm I've finished my work on #24 and it will get merged into master next week. Afterwards adding support for poetry would be very easy. I've changed the installed hook script to fail if autohooks couldn't be imported. It will need overriding the existing pre-commit hook script by running |
@alex-thewsey-ibm with #24 #28 and #29 this issue seems to be fixed for me. Please re-open if something is still missing. |
Hi team & thanks for a great library!
Our team uses an app development workflow based on pyenv and poetry - with autohooks and its plugins installed locally to the project+virtual environment.
Our devs are often not actually in the virtual environment shell when doing stuff: Instead using commands like
poetry run
to trigger scripts andpoetry add
to update dependencies.Unfortunately this often includes not being in the env when running
git commit
, andautohooks
is currently pretty lax about this per the example pre-commit hook below:I would love to see the ability (maybe via configuration if it's not for everybody?) to fail more forcefully in this case: For us it's much more likely that a forgetful developer is committing from the wrong environment than that there's an installation issue we want to tolerate!
The text was updated successfully, but these errors were encountered: