zsol / py.wtf

Autogenerated reference docs for PyPI packages
https://py.wtf
MIT License
10 stars 3 forks source link

chore: make ufmt Python 3.10 aware #90

Closed zsol closed 2 years ago

zsol commented 2 years ago

Stack from ghstack (oldest at bottom):

zsol commented 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 😉

asottile commented 2 years ago

I mean if your goal is to work on windows exec definitely doesn't (it spawns and then immediately exits 0) 😉

zsol commented 2 years ago

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
zsol commented 2 years ago

Oh you're totally right, actually. I'm the clown here.

asottile commented 2 years ago

lol

zsol commented 2 years ago

This should help: https://github.com/zsol/py.wtf/commit/a8afbf232c3525fe16c4fe6cd02f410c273c4642 Thanks, dude :)

asottile commented 2 years ago

personally I would raise SystemExit(subprocess.call((...))) that way you don't get a double stacktrace on failures

zsol commented 2 years ago

Fair. https://github.com/zsol/py.wtf/commit/e3ae95ba527755708aa5ad4d37510789a2373214

Did my "beached fish" impression above make a compelling case for supporting environment variables? 😄

asottile commented 2 years ago

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