work around Windows issue on latest Black

Thanks Rumo!
d797900386
This commit is contained in:
Damien Elmes 2021-05-13 20:15:51 +10:00
parent 99081e422b
commit c41d5ca4bf
4 changed files with 13 additions and 2 deletions

View file

@ -12,7 +12,7 @@ attrs==21.1.0
# pytest
beautifulsoup4==4.9.3
# via -r requirements.in
black==20.8b1
black==21.5b0
# via -r requirements.in
certifi==2020.12.5
# via requests

View file

@ -19,6 +19,10 @@ if __name__ == "__main__":
os.chdir(folder)
args = ["--diff", "--check"]
# work around issue with latest black
if sys.platform == "win32":
os.environ["USERPROFILE"] = os.environ["HOME"]
retcode = subprocess.run(
[
sys.executable,

View file

@ -5,7 +5,7 @@
Code for generating hooks.
"""
import re
import os
import subprocess
import sys
from dataclasses import dataclass
@ -161,6 +161,9 @@ def write_file(path: str, hooks: List[Hook], prefix: str, suffix: str):
code += "\n" + suffix
# work around issue with latest black
if sys.platform == "win32":
os.environ["USERPROFILE"] = os.environ["HOME"]
with open(path, "wb") as file:
file.write(code.encode("utf8"))
subprocess.run([sys.executable, "-m", "black", "-q", path], check=True)

View file

@ -18,6 +18,10 @@ if __name__ == "__main__":
os.chdir(folder)
args = ["--diff", "--check"]
# work around issue with latest black
if sys.platform == "win32":
os.environ["USERPROFILE"] = os.environ["HOME"]
retcode = subprocess.run(
[
sys.executable,