Skip to content
Snippets Groups Projects
Verified Commit fe469148 authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

The previously introduced methods do not comply with pep8

* removing prospector as it is not compatible with latest version of flake8
* introducting a new CI job that runs flake8 and actually fails if there are any errors
parent 9c96f66c
No related branches found
No related tags found
1 merge request!24Added convenience method to create test data
Pipeline #
...@@ -34,10 +34,10 @@ test_pytest: ...@@ -34,10 +34,10 @@ test_pytest:
paths: paths:
- .coverage - .coverage
test_prospector: test_flake8:
<<: *test_definition_backend <<: *test_definition_backend
script: script:
- prospector --uses django || exit 0 - flake8 --exclude=migrations --ignore=N802 core
# ----------------------------- Frontend subsection -------------------------- # # ----------------------------- Frontend subsection -------------------------- #
.test_template_frontend: &test_definition_frontend .test_template_frontend: &test_definition_frontend
......
...@@ -12,10 +12,3 @@ ...@@ -12,10 +12,3 @@
args: args:
- requirements.txt - requirements.txt
- requirements.dev.txt - requirements.dev.txt
- repo: local
hooks:
- id: prospector
name: prospector
entry: ./pre-commit-scripts/prospector.sh
language: script
types: [python]
grady_says = [
"Now let's see if we can improve this with a little water, sir.",
"Won't keep you a moment, sir.",
"Grady, sir. Delbert Grady.",
"Yes, sir.",
"That's right, sir.",
"Why no, sir. I don't believe so.",
"Ah ha, it's coming off now, sir.",
"Why no, sir. I don't believe so.",
"Yes, sir. I have a wife and two daughters, sir.",
"Oh, they're somewhere around. I'm not quite sure at the moment, sir.",
"That's strange, sir. I don't have any recollection of that at all.",
"I'm sorry to differ with you, sir, but you are the caretaker.",
"You have always been the caretaker, I should know, sir.",
"I've always been here.",
"Indeed, he is, Mr. Torrance. Avery willful boy. ",
"A rather naughty boy, if I may be so bold, sir.",
"Perhaps they need a good talking to, if you don't mind my saying so. Perhaps a bit more.",
"My girls, sir, they didn't care for the Overlook at first.",
"One of them actually stole a packet of matches and tried to burn it down.",
"But I corrected them, sir.",
"And when my wife tried to prevent me from doing my duty... I corrected her.",
]
...@@ -13,9 +13,8 @@ from typing import Dict, Union ...@@ -13,9 +13,8 @@ from typing import Dict, Union
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
from django.db import models from django.db import models
from django.db.models import Value as V
from django.db.models import (BooleanField, Case, Count, F, IntegerField, Q, from django.db.models import (BooleanField, Case, Count, F, IntegerField, Q,
QuerySet, Sum, When) QuerySet, Sum, Value, When)
from django.db.models.functions import Coalesce from django.db.models.functions import Coalesce
...@@ -125,7 +124,7 @@ class SubmissionType(models.Model): ...@@ -125,7 +124,7 @@ class SubmissionType(models.Model):
When( When(
Q(submissions__feedback__isnull=False) & Q(submissions__feedback__isnull=False) &
Q(submissions__feedback__status=Feedback.ACCEPTED), Q(submissions__feedback__status=Feedback.ACCEPTED),
then=V(1)), output_field=IntegerField(), then=Value(1)), output_field=IntegerField(),
) )
) )
).annotate( ).annotate(
...@@ -230,11 +229,12 @@ class Student(models.Model): ...@@ -230,11 +229,12 @@ class Student(models.Model):
the annotated QuerySet as described above. the annotated QuerySet as described above.
""" """
return cls.objects.annotate( return cls.objects.annotate(
overall_score=Coalesce(Sum('submissions__feedback__score'), V(0)), overall_score=Coalesce(Sum('submissions__feedback__score'),
Value(0)),
).annotate( ).annotate(
done=Case( done=Case(
When(exam__pass_score__lt=F('overall_score'), then=V(1)), When(exam__pass_score__lt=F('overall_score'), then=Value(1)),
default=V(0), default=Value(0),
output_field=BooleanField() output_field=BooleanField()
) )
) )
...@@ -362,12 +362,12 @@ class Submission(models.Model): ...@@ -362,12 +362,12 @@ class Submission(models.Model):
candidates = cls.objects.filter( candidates = cls.objects.filter(
( (
Q(feedback__isnull=True) Q(feedback__isnull=True) |
| Q(feedback__origin=Feedback.DID_NOT_COMPILE) Q(feedback__origin=Feedback.DID_NOT_COMPILE) |
| Q(feedback__origin=Feedback.COULD_NOT_LINK) Q(feedback__origin=Feedback.COULD_NOT_LINK) |
| Q(feedback__origin=Feedback.FAILED_UNIT_TESTS) Q(feedback__origin=Feedback.FAILED_UNIT_TESTS)
) ) &
& ~Q(feedback__of_tutor=tutor) ~Q(feedback__of_tutor=tutor)
) )
# we want a submission of a specific type # we want a submission of a specific type
...@@ -542,6 +542,7 @@ class Feedback(models.Model): ...@@ -542,6 +542,7 @@ class Feedback(models.Model):
) )
return tutor_feedback[0] if tutor_feedback else None return tutor_feedback[0] if tutor_feedback else None
@classmethod
def tutor_assigned_feedback(cls, user: Union[Tutor, Reviewer]): def tutor_assigned_feedback(cls, user: Union[Tutor, Reviewer]):
"""Gets all feedback that is assigned to the tutor including """Gets all feedback that is assigned to the tutor including
all status cases. all status cases.
......
#!/bin/bash
diff_files="$(git diff --cached --name-only --relative --diff-filter=AM)"
if [ -n "$diff_files" ]; then
prospector --uses django $diff_files
else
exit 0
fi
flake8~=3.5.0
pre-commit~=1.4.1 pre-commit~=1.4.1
prospector~=0.12.7
pytest-cov~=2.5.1 pytest-cov~=2.5.1
pytest-django~=3.1.2 pytest-django~=3.1.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment