From 58389b4f91523fcc17cf50d85618545af01bf548 Mon Sep 17 00:00:00 2001 From: Mike VanDenburgh Date: Fri, 5 Aug 2022 14:17:04 -0400 Subject: [PATCH] Configure `mypy` to run with `tox` --- mypy.ini | 9 --------- pyproject.toml | 22 ++++++++++++++++++++++ setup.py | 3 +++ tox.ini | 9 ++++----- 4 files changed, 29 insertions(+), 14 deletions(-) delete mode 100644 mypy.ini diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 10a444468..000000000 --- a/mypy.ini +++ /dev/null @@ -1,9 +0,0 @@ -[mypy] -plugins = - mypy_django_plugin.main - -[mypy.plugins.django-stubs] -django_settings_module = "dandiapi.settings" - -[mypy-celery.*] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index d95bea2c5..c4fe44a5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,3 +11,25 @@ line_length = 100 force_sort_within_sections = true # Combines "as" imports on the same line combine_as_imports = true + +[tool.mypy] +ignore_missing_imports = true +show_error_codes = true +disable_error_code = ["attr-defined", "var-annotated"] +follow_imports = "skip" # Don't follow imports into other files. This should be removed once all type errors have been resolved. +exclude = [ + "^dandiapi/api/admin.py", + "^dandiapi/api/mail.py", + "^dandiapi/api/tests/", + "^dandiapi/api/management/", + "^dandiapi/api/migrations/", + "^dandiapi/api/models/", + "^dandiapi/api/tasks/", + "^dandiapi/api/views/", +] + +# Re-enable these when https://github.com/typeddjango/django-stubs/issues/417 is fixed. +# plugins = ["mypy_django_plugin.main", "mypy_drf_plugin.main"] + +# [tool.django-stubs] +# django_settings_module = "dandiapi.settings" diff --git a/setup.py b/setup.py index c84055933..812e953ad 100644 --- a/setup.py +++ b/setup.py @@ -73,6 +73,9 @@ 'ipython', 'tox', 'boto3-stubs[s3]', + 'django-stubs', + 'djangorestframework-stubs', + 'types-setuptools', 'memray', ], 'test': [ diff --git a/tox.ini b/tox.ini index 4872b5af3..91f3beda8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,7 @@ [tox] envlist = lint, + type, test, check-migrations, @@ -19,14 +20,12 @@ commands = flake8 --config=tox.ini {posargs:.} [testenv:type] -skipsdist = true -skip_install = true deps = mypy - django-stubs - djangorestframework-stubs +extras = + dev commands = - mypy {posargs:.} + mypy {posargs:dandiapi/} [testenv:format] skipsdist = true