From 9e443736fd3a9370f9b29dab20f7169e29e21be5 Mon Sep 17 00:00:00 2001 From: Ian Lumsden Date: Thu, 14 Nov 2024 21:11:13 +0000 Subject: [PATCH] Adds type checking (through mypy) to CI --- .devcontainer/Dockerfile | 21 +-------------------- .github/workflows/unit-tests.yaml | 8 +++++++- hatchet/graphframe.py | 2 +- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index bf27765f..073251a4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -31,30 +31,11 @@ COPY requirements.txt /requirements.txt RUN python3 -m pip install -r requirements.txt -RUN python3 -m pip install --upgrade flake8-pytest-importorskip click==8.0.4 black==24.4.2 flake8==4.0.1 +RUN python3 -m pip install --upgrade flake8-pytest-importorskip click==8.0.4 black==24.4.2 flake8==4.0.1 mypy==1.13.0 RUN groupadd -g ${USER_GID} ${USERNAME} && \ adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \ echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers USER $USERNAME - -# FROM mcr.microsoft.com/devcontainers/miniconda:1-3 -# -# # Copy environment.yml (if found) to a temp location so we update the environment. Also -# # copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists. -# COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/ -# RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \ -# && rm -rf /tmp/conda-tmp -# -# COPY requirements.txt /requirements.txt -# -# RUN conda install -y python=3.9 \ -# && pip install --no-cache-dir pipx \ -# && pipx reinstall-all -# -# -# # [Optional] Uncomment this section to install additional OS packages. -# # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# # && apt-get -y install --no-install-recommends \ No newline at end of file diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 93d1abfc..412c7101 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -37,19 +37,25 @@ jobs: python setup.py build_ext --inplace python -m pip list - - name: Update Black + - name: Update Black and mypy if: ${{ matrix.python-version == 3.9 }} run: | pip install flake8-pytest-importorskip pip install --upgrade click==8.0.4 pip install black==24.4.2 pip install flake8==4.0.1 + pip install mypy==1.13.0 - name: Lint and Format Check with Flake8 and Black if: ${{ matrix.python-version == 3.9 }} run: | black --diff --check . flake8 + + - name: Run type checking with mypy + if: ${{ matrix.python-version == 3.9 }} + run: | + mypy hatchet --pretty - name: Check License Headers run: | diff --git a/hatchet/graphframe.py b/hatchet/graphframe.py index ffddcc8f..0b5fb04a 100644 --- a/hatchet/graphframe.py +++ b/hatchet/graphframe.py @@ -1092,7 +1092,7 @@ def tree( if color is False: try: - import IPython + import IPython # type: ignore[import-not-found] shell = IPython.get_ipython().__class__.__name__ except ImportError: