From e60332d637394b2d99f77291b4d958a63e8c9433 Mon Sep 17 00:00:00 2001 From: scosman Date: Sun, 18 Aug 2024 21:31:30 -0400 Subject: [PATCH] Add pyright for type checking and fix type errors. CI checked and working, as is checks.sh --- .github/workflows/build_and_test.yml | 10 +++++----- checks.sh | 12 +++++------- libs/core/kiln_ai/__init.__.py | 3 --- libs/core/pyproject.toml | 4 ++++ libs/studio/kiln_studio/server.py | 4 ++-- libs/studio/pyproject.toml | 4 ++++ requirements.txt | 3 +-- 7 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 libs/core/kiln_ai/__init.__.py diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 449fb64b..365f5da0 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -20,9 +20,9 @@ jobs: run: poetry install working-directory: ./libs/core - #- name: Build Core - # run: poetry build - # working-directory: ./libs/core + - name: Build Core + run: poetry build + working-directory: ./libs/core - name: Test Core run: python3 -m pytest tests/ @@ -41,9 +41,9 @@ jobs: working-directory: ./libs/studio - name: Check Types Core - run: mypy --install-types --non-interactive . + run: pyright . working-directory: ./libs/core - name: Check Types Studio - run: mypy --install-types --non-interactive . + run: pyright . working-directory: ./libs/studio diff --git a/checks.sh b/checks.sh index d1686e8a..5faf088c 100755 --- a/checks.sh +++ b/checks.sh @@ -40,11 +40,9 @@ cd libs/studio python3 -m pytest tests/ cd ../.. -# TODO test build? - echo "${headerStart}Checking Types${headerEnd}" -#cd libs/core -#mypy --install-types --non-interactive . -#cd ../studio -#mypy --install-types --non-interactive . -#cd ../.. +cd libs/core +pyright . +cd ../studio +pyright . +cd ../.. diff --git a/libs/core/kiln_ai/__init.__.py b/libs/core/kiln_ai/__init.__.py deleted file mode 100644 index 7d1d66fa..00000000 --- a/libs/core/kiln_ai/__init.__.py +++ /dev/null @@ -1,3 +0,0 @@ -import coreadd - -__all__ = ["coreadd"] diff --git a/libs/core/pyproject.toml b/libs/core/pyproject.toml index 391767aa..e5025ebd 100644 --- a/libs/core/pyproject.toml +++ b/libs/core/pyproject.toml @@ -23,3 +23,7 @@ python = ">=3.9" [tool.poetry.dev-dependencies] pytest = "^7.2" + +[tool.pyright] +strictListInference = true +reportMissingTypeArgument = true diff --git a/libs/studio/kiln_studio/server.py b/libs/studio/kiln_studio/server.py index 53f64b61..3fc56e65 100644 --- a/libs/studio/kiln_studio/server.py +++ b/libs/studio/kiln_studio/server.py @@ -12,7 +12,7 @@ # TODO would rather this get passed. This class shouldn't know about desktop def studio_path(): try: - base_path = sys._MEIPASS + base_path = sys._MEIPASS # type: ignore except Exception: base_path = os.path.join(os.path.dirname(__file__), "..") @@ -38,7 +38,7 @@ def load_settings(): @app.post("/setting") -def update_settings(new_settings: dict): +def update_settings(new_settings: dict[str, int | float | str | bool]): settings = load_settings() settings.update(new_settings) with open(settings_path(), "w") as f: diff --git a/libs/studio/pyproject.toml b/libs/studio/pyproject.toml index c8117c5f..6980ffcc 100644 --- a/libs/studio/pyproject.toml +++ b/libs/studio/pyproject.toml @@ -24,3 +24,7 @@ kiln-ai = "*" [tool.poetry.dev-dependencies] pytest = "^7.2.1" + +[tool.pyright] +reportMissingTypeArgument = true +strictListInference = true diff --git a/requirements.txt b/requirements.txt index 3853a8e8..be381771 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,8 +9,6 @@ importlib-resources==6.4.0 isort==5.13.2 jaraco.text==3.12.1 mccabe==0.7.0 -mypy==1.11.1 -mypy-extensions==1.0.0 ordered-set==4.1.0 pathspec==0.12.1 pipenv==2024.0.1 @@ -27,3 +25,4 @@ watchfiles==0.22.0 websockets==12.0 pytest==8.3.2 poetry==1.8.3 +pyright==1.1.376