diff --git a/.github/mypy_check.sh b/.github/mypy_check.sh new file mode 100755 index 00000000000..0058b1d2ee9 --- /dev/null +++ b/.github/mypy_check.sh @@ -0,0 +1,5 @@ +if [ "$(basename "$(pwd)")" = ".github" ]; then + cd .. +fi + +xargs mypy --strict --follow-imports=silent --no-warn-unused-ignore --install-types --non-interactive typings < .github/mypy_files.txt diff --git a/.github/mypy_files.txt b/.github/mypy_files.txt new file mode 100644 index 00000000000..0f0bef1ee41 --- /dev/null +++ b/.github/mypy_files.txt @@ -0,0 +1,2 @@ +worlds/AutoSNIClient.py +Patch.py diff --git a/.github/workflows/strict-type-check.yml b/.github/workflows/strict-type-check.yml new file mode 100644 index 00000000000..e448d27725e --- /dev/null +++ b/.github/workflows/strict-type-check.yml @@ -0,0 +1,27 @@ +name: type check + +on: + pull_request: + paths: + - "**.py" + push: + paths: + - "**.py" + +jobs: + mypy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: "Install dependencies" + run: | + python -m pip install --upgrade pip mypy + python ModuleUpdate.py --append "WebHostLib/requirements.txt" --force --yes + + - name: "mypy: strict check on specific files" + run: .github/mypy_check.sh diff --git a/ModuleUpdate.py b/ModuleUpdate.py index c3dc8c8a87b..ed041bef460 100644 --- a/ModuleUpdate.py +++ b/ModuleUpdate.py @@ -70,7 +70,7 @@ def install_pkg_resources(yes=False): subprocess.call([sys.executable, "-m", "pip", "install", "--upgrade", "setuptools"]) -def update(yes=False, force=False): +def update(yes: bool = False, force: bool = False) -> None: global update_ran if not update_ran: update_ran = True diff --git a/typings/kivy/uix/widget.pyi b/typings/kivy/uix/widget.pyi index 54e3b781ea0..bf736fae72f 100644 --- a/typings/kivy/uix/widget.pyi +++ b/typings/kivy/uix/widget.pyi @@ -1,7 +1,7 @@ """ FillType_* is not a real kivy type - just something to fill unknown typing. """ from typing import Any, Optional, Protocol -from ..graphics import FillType_Drawable, FillType_Vec +from ..graphics.texture import FillType_Drawable, FillType_Vec class FillType_BindCallback(Protocol): diff --git a/worlds/LauncherComponents.py b/worlds/LauncherComponents.py index 41c0bb83295..78ec14b4a4f 100644 --- a/worlds/LauncherComponents.py +++ b/worlds/LauncherComponents.py @@ -64,7 +64,7 @@ class SuffixIdentifier: def __init__(self, *args: str): self.suffixes = args - def __call__(self, path: str): + def __call__(self, path: str) -> bool: if isinstance(path, str): for suffix in self.suffixes: if path.endswith(suffix):