Closed zsol closed 2 years ago
So the story behind this is that pre-commit doesn't support setting environment variables for checks natively (https://github.com/pre-commit/pre-commit/issues/1157) and instead recommends we use env
, which is sensible. But, I refuse to give up my pre-commit hooks on Windows and this is the best way I could find of setting environment vars in a cross-platform way.
Maybe @asottile will look at the horrors in this PR and reconsider adding this feature to pre-commit 😉
I mean if your goal is to work on windows exec definitely doesn't (it spawns and then immediately exits 0) 😉
Nuh-uh 😄
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.execlp("pre-commit", "pre-commit", "--version")
PS C:\Users\zsolz> pre-commit 2.19.0
Oh you're totally right, actually. I'm the clown here.
lol
This should help: https://github.com/zsol/py.wtf/commit/a8afbf232c3525fe16c4fe6cd02f410c273c4642 Thanks, dude :)
personally I would raise SystemExit(subprocess.call((...)))
that way you don't get a double stacktrace on failures
Fair. https://github.com/zsol/py.wtf/commit/e3ae95ba527755708aa5ad4d37510789a2373214
Did my "beached fish" impression above make a compelling case for supporting environment variables? 😄
env
is going to be everywhere git
is :shrug: -- more compelling would be to write a python-env
or whatever though it looks like there's a handful of them on pypi already
Stack from ghstack (oldest at bottom):
92
89
88