From 6d4942302d49980ab9416b3d843cdb90443ab9ce Mon Sep 17 00:00:00 2001 From: beauxq Date: Tue, 16 Apr 2024 01:27:51 -0700 Subject: [PATCH] use Python instead of bash --- .github/pyright-config.json | 3 ++- .github/type_check.py | 23 +++++++++++++++++++++++ .github/type_check.sh | 5 ----- .github/workflows/strict-type-check.yml | 4 +--- 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 .github/type_check.py delete mode 100755 .github/type_check.sh diff --git a/.github/pyright-config.json b/.github/pyright-config.json index 2e9635706c..6ad7fa5f19 100644 --- a/.github/pyright-config.json +++ b/.github/pyright-config.json @@ -1,5 +1,6 @@ { "include": [ + "type_check.py", "../worlds/AutoSNIClient.py", "../Patch.py" ], @@ -16,7 +17,7 @@ "reportMissingTypeStubs": true, "pythonVersion": "3.8", - "pythonPlatform": "Linux", + "pythonPlatform": "Windows", "executionEnvironments": [ { diff --git a/.github/type_check.py b/.github/type_check.py new file mode 100644 index 0000000000..983db9c9bd --- /dev/null +++ b/.github/type_check.py @@ -0,0 +1,23 @@ +from pathlib import Path +import subprocess +import sys + +config = Path(__file__).parent / "pyright-config.json" + +command = ("pyright", "-p", str(config)) +print(" ".join(command)) + +try: + result = subprocess.run( + ("pyright", "-p", str(config)), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) +except FileNotFoundError as e: + print(f"{e} - Is pyright installed?") + exit(1) + +sys.stdout.write((result.stdout or b"").decode()) +sys.stderr.write((result.stderr or b"").decode()) + +exit(result.returncode) diff --git a/.github/type_check.sh b/.github/type_check.sh deleted file mode 100755 index 08b3954518..0000000000 --- a/.github/type_check.sh +++ /dev/null @@ -1,5 +0,0 @@ -if [ "$(basename "$(pwd)")" = ".github" ]; then - cd .. -fi - -pyright -p .github/pyright-config.json diff --git a/.github/workflows/strict-type-check.yml b/.github/workflows/strict-type-check.yml index 2d4224921d..bafd572a26 100644 --- a/.github/workflows/strict-type-check.yml +++ b/.github/workflows/strict-type-check.yml @@ -4,14 +4,12 @@ on: pull_request: paths: - "**.py" - - ".github/type_check.sh" - ".github/pyright-config.json" - ".github/workflows/strict-type-check.yml" - "**.pyi" push: paths: - "**.py" - - ".github/type_check.sh" - ".github/pyright-config.json" - ".github/workflows/strict-type-check.yml" - "**.pyi" @@ -32,4 +30,4 @@ jobs: python ModuleUpdate.py --append "WebHostLib/requirements.txt" --force --yes - name: "pyright: strict check on specific files" - run: .github/type_check.sh + run: python .github/type_check.py