diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 7fd04a9e9..6775e2f21 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -58,6 +58,11 @@ jobs: run: | make check-format + - name: Verify code can run with mypy (not Windows) + if: steps.install.outcome == 'success' && (success() || failure()) && matrix.os != 'windows-latest' + run: | + make ci-check-mypy-can-run + pypi: name: "Deploy to PyPI" runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 22a67d7cd..cc6eb67f2 100644 --- a/Makefile +++ b/Makefile @@ -225,6 +225,14 @@ ci-install-rsconnect: FORCE uv pip install "rsconnect-python @ git+https://github.com/rstudio/rsconnect-python.git" +# This is just to check if mypy can run for other users. +# Not added to `make check` or `make check-fix` as all lint errors are supporessed (as we use pyright). +ci-check-mypy-can-run: FORCE + @echo "-------- Checking types with mypy -----------" + uv pip install mypy + mypy shiny + + # ## If caching is ever used, we could run: # install-deps: FORCE ## install latest dependencies # pip install --editable ".[dev,test]" --upgrade --upgrade-strategy eager diff --git a/pyproject.toml b/pyproject.toml index ca94dbb50..079839741 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -144,3 +144,10 @@ ignore = ["E302", "E501", "F403", "F405", "W503", "E203", "E701", "E704"] [tool.isort] profile = "black" skip = ["__init__.py", "typings/", "_dev/", ".venv", "venv", ".tox", "build"] + +[tool.mypy] +# The goal of our usage of mypy is to make to sure mypy can run, not that it catches any errors (we use pyright to find our errors). +# Therefore, ignore_errors but do not ignore runtime errors while checking +# Note: This setting can not be done via CLI and must be set within a config +ignore_errors = true +exclude = ["shiny/api-examples", "shiny/templates"] diff --git a/shiny/render/_data_frame_utils/_selection.py b/shiny/render/_data_frame_utils/_selection.py index fb86a3175..52125f5b6 100644 --- a/shiny/render/_data_frame_utils/_selection.py +++ b/shiny/render/_data_frame_utils/_selection.py @@ -150,8 +150,8 @@ def _has_rect(self) -> bool: # Should only contain a single selection area # Do not include `BrowserCellSelectionAll` as it should be represented by a row, column, or region with appropriate values. -# class BrowserCellSelectionAll(TypedDict): -# type: Literal["all"] +# # class BrowserCellSelectionAll(TypedDict): +# # type: Literal["all"] class BrowserCellSelectionNone(TypedDict):