-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check answers for integer and float #173
Check answers for integer and float #173
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable thank you ! Could you add covering tests for it, please ?
2d88fab
to
dc89aee
Compare
@Pierre-Sassoulas I added covering tests. Thanks for the quick reply |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding tests ! The current issue with the pipeline is due to a function that became too complex survey/models/answer.py:57:5: C901 'Answer.check_answer_body' is too complex (14)
. Would you mind doing a refactor first ?
Maybe a visitor pattern like:
def check_answer_body(self, question, body):
func = getattr("check_answer_body_for_{question.type.lower()}")
return func(question, body)
def check_answer_body_for_integer(self, question, body):
if body and body != "":
try:
body = int(body)
except ValueError:
msg = "Answer is not an integer"
raise ValidationError(msg)
6771176
to
14d7dc3
Compare
for more information, see https://pre-commit.ci
@Pierre-Sassoulas I changed a little bit the function :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for refactoring 👍
I released this in 1.4.4 it should be available shortly. |
Perfect, thanks :) |
No description provided.