From ec6a95f2d1bd7020a35beae484ab5f427ed0bb0c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 15 Jan 2018 15:42:13 -0600 Subject: [PATCH] Upgrade mypy --- .gitlab-ci.yml | 2 +- course/auth.py | 3 ++- course/page/text.py | 4 +++- run-travis-ci.sh | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c53c667f..064060d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ Documentation: Mypy: script: - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-mypy.sh - - ". ./prepare-and-run-mypy.sh python3.6 mypy==0.521 typed-ast==1.0.4" + - ". ./prepare-and-run-mypy.sh python3.6 mypy==0.560" tags: - python3.6 except: diff --git a/course/auth.py b/course/auth.py index 6cfed74b..65212907 100644 --- a/course/auth.py +++ b/course/auth.py @@ -68,7 +68,7 @@ from relate.utils import StyledForm, StyledModelForm, string_concat, get_site_na from django_select2.forms import ModelSelect2Widget if False: - from typing import Any, Text # noqa + from typing import Any, Text, Optional # noqa from django.db.models import query # noqa @@ -1178,6 +1178,7 @@ class APIContext(object): self.restrict_to_role = restrict_to_role def has_permission(self, perm, argument=None): + # type: (Text, Optional[Text]) -> bool if self.restrict_to_role is None: return self.participation.has_permission(perm, argument) else: diff --git a/course/page/text.py b/course/page/text.py index dc5a5fb2..61fce936 100644 --- a/course/page/text.py +++ b/course/page/text.py @@ -38,6 +38,8 @@ from course.page.base import ( get_editor_interaction_mode) +from typing import cast + import re import sys @@ -308,7 +310,7 @@ class RegexMatcher(TextAnswerMatcher): class CaseSensitiveRegexMatcher(RegexMatcher): type = "case_sens_regex" - re_flags = 0 + re_flags = cast(re.RegexFlag, 0) is_case_sensitive = True pattern_type = "string" diff --git a/run-travis-ci.sh b/run-travis-ci.sh index f54ca49e..9ae669a0 100644 --- a/run-travis-ci.sh +++ b/run-travis-ci.sh @@ -13,7 +13,7 @@ fi if [[ $PY == true ]]; then . ./run-tests-for-ci.sh elif [[ $Mypy == true ]]; then - . ./prepare-and-run-mypy.sh python3.6 mypy==0.521 typed-ast==1.0.4 + . ./prepare-and-run-mypy.sh python3.6 mypy==0.560 elif [[ $Flake8 == true ]]; then . ./prepare-and-run-flake8.sh relate course accounts tests bin -fi \ No newline at end of file +fi -- GitLab