diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 75085bf06e04d8e454c6570e5e3181bf8a0e9c58..9406b9afe6d479af6a68be5265bd36c54ce2c6fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,3 +33,12 @@ Mypy: - python3.5 except: - tags + +Flake8: + script: + - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh + - ". ./prepare-and-run-flake8.sh relate course accounts test bin" + tags: + - python3.5 + except: + - tags diff --git a/accounts/__init__.py b/accounts/__init__.py index d409344bec94be25d0aec6cc1b4e7a868c57cbf3..8319823191b94c101df51a5f8af026671f85f567 100644 --- a/accounts/__init__.py +++ b/accounts/__init__.py @@ -1 +1 @@ -default_app_config = 'accounts.apps.AccountsConfig' \ No newline at end of file +default_app_config = 'accounts.apps.AccountsConfig' diff --git a/accounts/apps.py b/accounts/apps.py index fcad9b4ff44b22b6e8d20189fbb283cd4b1e5e07..b5b68ddd974ac9513a7f807b21ce00152eb23ed1 100644 --- a/accounts/apps.py +++ b/accounts/apps.py @@ -5,4 +5,4 @@ from django.utils.translation import ugettext_lazy as _ class AccountsConfig(AppConfig): name = 'accounts' # for translation of the name of "Accounts" app displayed in admin. - verbose_name = _("Accounts") \ No newline at end of file + verbose_name = _("Accounts") diff --git a/accounts/tests.py b/accounts/tests.py index 7ce503c2dd97ba78597f6ff6e4393132753573f6..9a30df3b5ce14e751c2215fafcf2141c38ee9946 100644 --- a/accounts/tests.py +++ b/accounts/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +from django.test import TestCase # noqa # Create your tests here. diff --git a/accounts/views.py b/accounts/views.py index 91ea44a218fbd2f408430959283f0419c921093e..6100593bc427cadce19dee2f7eb0c7f1473a8ad9 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1,3 +1,3 @@ -from django.shortcuts import render +from django.shortcuts import render # noqa # Create your views here. diff --git a/course/__init__.py b/course/__init__.py index 1dab58eb27c37a210fe8f076e8ff8680cf9ade32..10308e50109453da49fbc2072499f878365a0e17 100644 --- a/course/__init__.py +++ b/course/__init__.py @@ -1 +1 @@ -default_app_config = 'course.apps.CourseConfig' \ No newline at end of file +default_app_config = 'course.apps.CourseConfig' diff --git a/course/apps.py b/course/apps.py index 02031fe5851921f4844a24458a5051bcb47b6c17..58f78b149194b87a83c9d41cb45ac2bfa2dece17 100644 --- a/course/apps.py +++ b/course/apps.py @@ -8,4 +8,4 @@ class CourseConfig(AppConfig): verbose_name = _("Course module") def ready(self): - import course.receivers \ No newline at end of file + import course.receivers # noqa diff --git a/course/constants.py b/course/constants.py index f17cd17ebbef40d7af80574763047f65506567eb..063ab3dd6637ff9d35e4114f7eead6394cd7db83 100644 --- a/course/constants.py +++ b/course/constants.py @@ -73,7 +73,7 @@ PARTICIPATION_STATUS_CHOICES = ( # {{{ participation permission -class participation_permission: +class participation_permission: # noqa edit_course = "edit_course" use_admin_interface = "use_admin_interface" diff --git a/course/enrollment.py b/course/enrollment.py index 6e7386550b7781fc238ea3d8c0b868a77597b597..460dc2150b301a085505494feb7078bc1a5540bc 100644 --- a/course/enrollment.py +++ b/course/enrollment.py @@ -67,7 +67,7 @@ from course.utils import course_view, render_course_page from relate.utils import StyledForm, StyledModelForm -from pytools.lex import RE as REBase +from pytools.lex import RE as REBase # noqa # {{{ for mypy diff --git a/course/flow.py b/course/flow.py index 74d6cac8d5da767d7526dc96b0344995f38e35c2..dfa2b1bf913598c1ace75633eaaeef7c8fb49d58 100644 --- a/course/flow.py +++ b/course/flow.py @@ -2281,7 +2281,7 @@ class FlowPageInteractionEmailForm(StyledForm): self.fields["message"] = forms.CharField( required=True, widget=forms.Textarea, - help_text= string_concat( + help_text=string_concat( _("Your questions about page %s . ") % review_uri, _("Notice that only questions " "for that page will be answered."), diff --git a/course/page/base.py b/course/page/base.py index 741ca898b0e4c26913cb36ec975fa4f816930db8..a5742323b4a021056f0d78d8c01d9e101de7b2e8 100644 --- a/course/page/base.py +++ b/course/page/base.py @@ -995,20 +995,20 @@ class PageBaseWithHumanTextFeedback(PageBase): msg.send() if (grading_form.cleaned_data["notes"] - and grading_form.cleaned_data["notify_instructor"] - and page_context.flow_session): + and grading_form.cleaned_data["notify_instructor"] + and page_context.flow_session): with translation.override(settings.RELATE_ADMIN_EMAIL_LOCALE): from django.template.loader import render_to_string - from django.urls import reverse - message = render_to_string("course/grade-internal-notes-notify.txt", { - "page_title": self.title(page_context, page_data), - "course": page_context.course, - "participation": page_context.flow_session.participation, - "notes_text": grade_data["notes"], - "flow_session": page_context.flow_session, - "review_uri": page_context.page_uri, - "sender": request.user - }) + message = render_to_string("course/grade-internal-notes-notify.txt", + { + "page_title": self.title(page_context, page_data), + "course": page_context.course, + "participation": page_context.flow_session.participation, + "notes_text": grade_data["notes"], + "flow_session": page_context.flow_session, + "review_uri": page_context.page_uri, + "sender": request.user + }) from django.core.mail import EmailMessage msg = EmailMessage( diff --git a/course/page/inline.py b/course/page/inline.py index caa856ca723be153de54489fe11a3ded0ab996a5..d1fb92b393e229bd4c910bfcf1c37a38650e36bb 100644 --- a/course/page/inline.py +++ b/course/page/inline.py @@ -43,7 +43,7 @@ import re # {{{ multiple text question -from crispy_forms.layout import Layout, Field, HTML +from crispy_forms.layout import Layout, HTML from crispy_forms.bootstrap import PrependedAppendedText @@ -459,11 +459,12 @@ class ChoicesAnswer(AnswerBase): def get_correct_answer_text(self, page_context): corr_idx = self.correct_indices()[0] return ("%s%s%s" - % (getattr(self.answers_desc, "prepended_text", "").strip(), - self.process_choice_string( - page_context, self.answers_desc.choices[corr_idx]).lstrip(), - getattr(self.answers_desc, "appended_text", "").strip()) - ) + % ( + getattr(self.answers_desc, "prepended_text", "").strip(), + self.process_choice_string( + page_context, self.answers_desc.choices[corr_idx]).lstrip(), + getattr(self.answers_desc, "appended_text", "").strip()) + ) def get_max_correct_answer_len(self, page_context): return max([len(answer) for answer in @@ -821,7 +822,7 @@ class InlineMultiQuestion(TextQuestionBase, PageBaseWithValue): correctness_list.append(answer_instance.get_correctness( answer[answer_instance.name])) - # The answer doesn't exist for newly added question + # The answer doesn't exist for newly added question # for pages which have been submitted. except KeyError: correctness_list.append(1) diff --git a/course/templatetags/coursetags.py b/course/templatetags/coursetags.py index bda5a5ac1a9a8ae198d369ec72cffc24058f2f82..c48bf73d1ea8ae2a24c42a1fc70558ee81e7066a 100644 --- a/course/templatetags/coursetags.py +++ b/course/templatetags/coursetags.py @@ -30,6 +30,7 @@ register = Library() # {{{ get language_code in JS traditional naming format + class GetCurrentLanguageJsFmtNode(Node): def __init__(self, variable): self.variable = variable @@ -39,6 +40,7 @@ class GetCurrentLanguageJsFmtNode(Node): context[self.variable] = js_lang_name return '' + @register.tag("get_current_js_lang_name") def do_get_current_js_lang_name(parser, token): """ diff --git a/course/tests.py b/course/tests.py index 7ce503c2dd97ba78597f6ff6e4393132753573f6..9a30df3b5ce14e751c2215fafcf2141c38ee9946 100644 --- a/course/tests.py +++ b/course/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +from django.test import TestCase # noqa # Create your tests here. diff --git a/relate/utils.py b/relate/utils.py index 52ad19b9bd45da8e6f0ac654a42c7800df09e0eb..54e15f787529b0e7277131f2d2a2dd4c3ae14bcc 100644 --- a/relate/utils.py +++ b/relate/utils.py @@ -267,7 +267,7 @@ def retry_transaction(f, args, kwargs={}, max_tries=None, serializable=None): sleep(uniform(0.05, 0.2)) -class retry_transaction_decorator(object): +class retry_transaction_decorator(object): # noqa def __init__(self, max_tries=None, serializable=None): # type: (Optional[int], Optional[bool]) -> None self.max_tries = max_tries diff --git a/setup.cfg b/setup.cfg index 77f81d3bfbff0b437d7d65c0bcda8064887aa084..4670a3c154b4d105bd48cc15a2a39b9c8ead208f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,4 @@ [flake8] ignore = E126,E127,E128,E123,E226,E241,E242,E265,E402,W503 max-line-length=85 +exclude=course/migrations,accounts/migrations,static,components,course/mdx_mathjax.py