From d7a05cf69d30e7bdb2b735ad30cb26f1dc5ec1a9 Mon Sep 17 00:00:00 2001 From: Denis Orehovsky Date: Mon, 2 Jul 2018 10:22:48 +0300 Subject: [PATCH 1/2] Add mypy to the local dependencies --- {{cookiecutter.project_slug}}/README.rst | 9 +++++++++ .../requirements/local.txt | 1 + {{cookiecutter.project_slug}}/setup.cfg | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/{{cookiecutter.project_slug}}/README.rst b/{{cookiecutter.project_slug}}/README.rst index 3386d9855..2f40710e2 100644 --- a/{{cookiecutter.project_slug}}/README.rst +++ b/{{cookiecutter.project_slug}}/README.rst @@ -32,6 +32,15 @@ Setting Up Your Users For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users. +Type checks +^^^^^^^^^^^ + +Running type checks with mypy: + +:: + + $ mypy {{cookiecutter.project_slug}} + Test coverage ^^^^^^^^^^^^^ diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 63799d990..b8a7609c2 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -11,6 +11,7 @@ psycopg2-binary==2.7.5 # https://github.com/psycopg/psycopg2 # Testing # ------------------------------------------------------------------------------ +mypy==0.610 # https://github.com/python/mypy pytest==3.6.2 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.1 # https://github.com/Frozenball/pytest-sugar diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index 1ec89c789..c2139f1db 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -5,3 +5,17 @@ exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules [pycodestyle] max-line-length = 120 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules + +[mypy] +python_version = 3.6 +check_untyped_defs = True +ignore_errors = False +ignore_missing_imports = True +strict_optional = True +warn_unused_ignores = True +warn_redundant_casts = True +warn_unused_configs = True + +[mypy-*.migrations.*] +# Django migrations should not produce any errors: +ignore_errors = True From c18a2fca8c5ddc5cf458f4f473bb07b036aed2e4 Mon Sep 17 00:00:00 2001 From: Denis Orehovsky Date: Sun, 19 Aug 2018 14:08:29 +0300 Subject: [PATCH 2/2] Run type checks in test_docker --- tests/test_docker.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_docker.sh b/tests/test_docker.sh index 78c5717a6..0fd81604b 100755 --- a/tests/test_docker.sh +++ b/tests/test_docker.sh @@ -14,6 +14,9 @@ cd .cache/docker cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y cd my_awesome_project +# run the project's type checks +docker-compose -f local.yml run django mypy my_awesome_project + # run the project's tests docker-compose -f local.yml run django python manage.py pytest