CI: strict mypy check in github actions

mypy_files.txt is a list of files that will fail the CI if mypy finds errors in them
This commit is contained in:
beauxq
2024-04-06 10:53:21 -07:00
parent 885fb4aabe
commit caa31a5823
6 changed files with 37 additions and 3 deletions

5
.github/mypy_check.sh vendored Executable file
View File

@@ -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

2
.github/mypy_files.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
./worlds/AutoSNIClient.py
./Patch.py

27
.github/workflows/strict-type-check.yml vendored Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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):

View File

@@ -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):