From 76853c325fb3fef9a242c219e7f429c0c7c2c1e8 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 1 May 2023 18:43:05 -0400 Subject: [PATCH 1/4] Add stubdefaulter to create_baseline_stubs --- requirements-tests.txt | 1 + scripts/create_baseline_stubs.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/requirements-tests.txt b/requirements-tests.txt index 8a233763d289..7cba0f191750 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -12,6 +12,7 @@ pre-commit-hooks==4.4.0 # must match .pre-commit-confi pycln==2.1.3 # must match .pre-commit-config.yaml pytype==2023.4.27; platform_system != "Windows" and python_version < "3.11" pyyaml==6.0 +stubdefaulter==0.1.0 termcolor>=2.3 tomli==2.0.1 tomlkit==0.11.8 diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index ed28b8c61aa1..f025293de4d2 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -50,6 +50,11 @@ def run_stubgen(package: str, output: str) -> None: subprocess.run(["stubgen", "-o", output, "-p", package, "--export-less"], check=True) +def run_stubdefaulter(stub_dir: str) -> None: + print(f"Running stubdefaulter: stubdefaulter --packages {stub_dir}") + subprocess.run(["stubdefaulter", "--packages", stub_dir]) + + def run_black(stub_dir: str) -> None: print(f"Running black: black {stub_dir}") subprocess.run(["black", stub_dir]) @@ -153,6 +158,7 @@ def main() -> None: run_stubgen(package, stub_dir) + run_stubdefaulter(stub_dir) run_isort(stub_dir) run_black(stub_dir) From 40c155a876a20dd5a9a83ea9f7a633ac471d21f6 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 1 May 2023 18:50:50 -0400 Subject: [PATCH 2/4] move up 1 line --- scripts/create_baseline_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index f025293de4d2..8fb26eb58d3d 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -157,8 +157,8 @@ def main() -> None: sys.exit(f"Error: {package_dir} already exists (delete it first)") run_stubgen(package, stub_dir) - run_stubdefaulter(stub_dir) + run_isort(stub_dir) run_black(stub_dir) From 89edd8aa28ea0770c3b9ea38c2db114656c692b0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 22:51:57 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks --- scripts/create_baseline_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 8fb26eb58d3d..66290243682b 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -158,7 +158,7 @@ def main() -> None: run_stubgen(package, stub_dir) run_stubdefaulter(stub_dir) - + run_isort(stub_dir) run_black(stub_dir) From c2b060cacf0dfca6a56674285e14154e7d128fd7 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 2 May 2023 11:15:10 +0100 Subject: [PATCH 4/4] Fix another issue while we're here so it works well on Windows --- scripts/create_baseline_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 66290243682b..4675ee58bce0 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -62,7 +62,7 @@ def run_black(stub_dir: str) -> None: def run_isort(stub_dir: str) -> None: print(f"Running isort: isort {stub_dir}") - subprocess.run(["python3", "-m", "isort", stub_dir]) + subprocess.run([sys.executable, "-m", "isort", stub_dir]) def create_metadata(stub_dir: str, version: str) -> None: