Skip to content

Commit

Permalink
Add pyright for type checking and fix type errors. CI checked and wor…
Browse files Browse the repository at this point in the history
…king, as is checks.sh
  • Loading branch information
scosman committed Aug 19, 2024
1 parent 0f9e329 commit e60332d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
12 changes: 5 additions & 7 deletions checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../..
3 changes: 0 additions & 3 deletions libs/core/kiln_ai/__init.__.py

This file was deleted.

4 changes: 4 additions & 0 deletions libs/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ python = ">=3.9"

[tool.poetry.dev-dependencies]
pytest = "^7.2"

[tool.pyright]
strictListInference = true
reportMissingTypeArgument = true
4 changes: 2 additions & 2 deletions libs/studio/kiln_studio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__), "..")

Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions libs/studio/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ kiln-ai = "*"

[tool.poetry.dev-dependencies]
pytest = "^7.2.1"

[tool.pyright]
reportMissingTypeArgument = true
strictListInference = true
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,3 +25,4 @@ watchfiles==0.22.0
websockets==12.0
pytest==8.3.2
poetry==1.8.3
pyright==1.1.376

0 comments on commit e60332d

Please sign in to comment.