Skip to content

Commit

Permalink
Add mypy to new lint action
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Weinberg <[email protected]>
  • Loading branch information
nathan-weinberg committed Jun 5, 2024
1 parent eb59e4d commit 5bfc0bb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

name: Lint and Format
name: Lint, Format, and MyPy

on:
push:
Expand Down Expand Up @@ -50,6 +50,7 @@ jobs:
**/requirements*.txt
- name: Install dependencies
id: deps
run: |
python -m pip install --upgrade pip
python -m pip install tox
Expand All @@ -59,7 +60,12 @@ jobs:
tox -e ruff -- check
- name: Run linting
if: success() || failure()
if: ${{ !cancelled() && (steps.deps.outcome == 'success') }}
run: |
echo "::add-matcher::.github/workflows/matchers/pylint.json"
tox -e lint
- name: Run mypy type checks
if: ${{ !cancelled() && (steps.deps.outcome == 'success') }}
run: |
tox -e mypy
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ source = "https://github.com/instructlab/sdg"
issues = "https://github.com/instructlab/sdg/issues"

[tool.setuptools_scm]
version_file = "src/sdg/_version.py"
version_file = "src/instructlab_sdg/_version.py"
# do not include +gREV local version, required for Test PyPI upload
local_scheme = "no-local-version"

Expand Down Expand Up @@ -103,3 +103,12 @@ from-first = true
# import-heading-firstparty=First Party
# import-heading-localfolder=Local
known-local-folder = ["tuning"]

[tool.mypy]
disable_error_code = ["import-not-found", "import-untyped"]
exclude = [
"^src/instructlab_sdg/generate_data\\.py$",
"^src/instructlab_sdg/utils\\.py$",
]
# honor excludes by not following there through imports
follow_imports = "silent"
12 changes: 11 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[tox]
# py3-unit runs unit tests with 'python3'
# py311-unit runs the same tests with 'python3.11'
envlist = ruff, lint, spellcheck
envlist = ruff, lint, mypy, spellcheck
minversion = 4.4

# format, check, and linting targets don't build and install the project to
Expand Down Expand Up @@ -49,3 +49,13 @@ commands =
sh -c 'command -v aspell || (echo "aspell is not installed. Please install it." && exit 1)'
{envpython} -m pyspelling --config {toxinidir}/.spellcheck.yml --spellchecker aspell
allowlist_externals = sh

[testenv:mypy]
description = Python type checking with mypy
deps =
mypy>=1.10.0,<2.0
types-tqdm
types-PyYAML
pytest
commands =
mypy src

0 comments on commit 5bfc0bb

Please sign in to comment.