From c41d5ca4bf8b6a3003fc903f634959dcbb62e730 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 13 May 2021 20:15:51 +1000 Subject: [PATCH] work around Windows issue on latest Black Thanks Rumo! https://github.com/ankitects/anki/commit/d7979003860ec411caff0ddf939657054f62ee93 --- pip/requirements.txt | 2 +- pylib/tests/run_format.py | 4 ++++ pylib/tools/hookslib.py | 5 ++++- qt/tests/run_format.py | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pip/requirements.txt b/pip/requirements.txt index 3e89afdfd..bc2ace9e2 100644 --- a/pip/requirements.txt +++ b/pip/requirements.txt @@ -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 diff --git a/pylib/tests/run_format.py b/pylib/tests/run_format.py index 8bc386995..82edff2a2 100644 --- a/pylib/tests/run_format.py +++ b/pylib/tests/run_format.py @@ -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, diff --git a/pylib/tools/hookslib.py b/pylib/tools/hookslib.py index f8262aa92..defd28305 100644 --- a/pylib/tools/hookslib.py +++ b/pylib/tools/hookslib.py @@ -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) diff --git a/qt/tests/run_format.py b/qt/tests/run_format.py index 622dd4399..f0a4f5e36 100644 --- a/qt/tests/run_format.py +++ b/qt/tests/run_format.py @@ -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,