From 8a712d46b51311e0450cc760d181db9c16f60d19 Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Sat, 5 Jan 2019 19:10:23 +0300 Subject: [PATCH] typecheck django tests, allow failures --- .travis.yml | 12 ++++++++++-- scripts/.gitignore | 1 + scripts/typecheck_django_tests.xsh | 14 ++++++++++++++ scripts/typecheck_tests.ini | 10 ++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 scripts/.gitignore create mode 100755 scripts/typecheck_django_tests.xsh create mode 100644 scripts/typecheck_tests.ini diff --git a/.travis.yml b/.travis.yml index e163572..8312c20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,19 +7,27 @@ sudo: required jobs: include: - - name: "run test suite with python 3.7" + - name: "Run plugin test suite with python 3.7" python: 3.7 script: | set -e pytest + - name: "Lint with black" python: 3.7 script: | black --check --line-length=120 django-stubs/ + allow_failures: + - name: "Typecheck Django test suite" + python: 3.7 + script: | + cd scripts + ./typecheck_django_tests.xsh + before_install: | # Upgrade pip, setuptools, and wheel - pip install -U pip setuptools wheel + pip install -U pip setuptools wheel xonsh install: | pip install -r ./dev-requirements.txt diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 0000000..9d57190 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1 @@ +django-sources/ diff --git a/scripts/typecheck_django_tests.xsh b/scripts/typecheck_django_tests.xsh new file mode 100755 index 0000000..4797002 --- /dev/null +++ b/scripts/typecheck_django_tests.xsh @@ -0,0 +1,14 @@ +#!/usr/local/bin/xonsh + +import os +if not os.path.exists('./django-sources'): + git clone -b stable/2.1.x https://github.com/django/django.git django-sources + +ignored_error_patterns = ["Need type annotation for"] +for line in $(mypy --config-file typecheck_tests.ini ./django-sources/tests/files).split('\n'): + for pattern in ignored_error_patterns: + if pattern in line: + break + else: + print(line) + diff --git a/scripts/typecheck_tests.ini b/scripts/typecheck_tests.ini new file mode 100644 index 0000000..162dd63 --- /dev/null +++ b/scripts/typecheck_tests.ini @@ -0,0 +1,10 @@ +[mypy] +strict_optional = False +ignore_missing_imports = True +check_untyped_defs = True +warn_no_return = False +show_traceback = True +warn_redundant_casts = True + +plugins = + mypy_django_plugin.main