Skip to content

Commit

Permalink
Add MyPy type checking and a GitHub Action to automatically check this.
Browse files Browse the repository at this point in the history
  • Loading branch information
YPCrumble committed Aug 23, 2024
1 parent 9d4fb5d commit ebc2e88
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Run mypy
on:
pull_request:
push:
branches: ["main", "v[0-9]*"]
tags: ["v[0-9]*"]
workflow_dispatch:
jobs:
mypy:
runs-on: ubuntu-22.04
steps:
- name: apt update
run: sudo apt update
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements-dev.txt
- name: MyPy
run: mypy .
26 changes: 26 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[mypy]
plugins = mypy_django_plugin.main
# TODO: Check all code in the future
check_untyped_defs = False
disallow_any_generics = False
disallow_incomplete_defs = False
disallow_subclassing_any = False
disallow_untyped_calls = False
disallow_untyped_defs = False
ignore_missing_imports = True
no_implicit_optional = True
no_implicit_reexport = True
strict = True
warn_return_any = False
# TODO: Remove this exception in the future
disable_error_code = var-annotated

[mypy.plugins.django-stubs]
django_settings_module = "tests.test_settings.settings_5_0"

# TODO: Type check tests in the future
[mypy-tests.*]
ignore_errors = True

[mypy-docs.*]
ignore_errors = True
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Requirements for developing (not just using) the package

django-stubs
hatch
mypy
pre-commit
requests
tox<4
types-requests

0 comments on commit ebc2e88

Please sign in to comment.