Skip to content

Commit be61bd5

Browse files
[pylint] Fix 'possibly-used-before-assignment'
1 parent 752c337 commit be61bd5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

survey/management/survey_command.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ def add_arguments(self, parser):
2828
def raise_value_error(error_type, value):
2929
"""Raise a ValueError with a clean error message in python 2.7 and 3.
3030
:param string value: the attempted value."""
31+
valid_texts = []
32+
base = "--question-id {} / --question-text '{}'\n"
3133
if error_type in ["question-id", "question-text"]:
32-
base = "--question-id {} / --question-text '{}'\n"
33-
valids = [(q.pk, q.text) for q in Question.objects.all()]
34+
valid_texts = [(q.pk, q.text) for q in Question.objects.all()]
3435
elif error_type in ["survey-name", "survey-id"]:
3536
base = "--survey-id {} / --survey-name '{}'\n"
36-
valids = [(s.pk, s.name) for s in Survey.objects.all()]
37+
valid_texts = [(s.pk, s.name) for s in Survey.objects.all()]
3738
msg = f"You tried to get --{error_type} '{value}' "
38-
if valids:
39+
if valid_texts:
3940
msg += "but is does not exists. Possibles values :\n"
40-
for primary_key, name in valids:
41+
for primary_key, name in valid_texts:
4142
msg += base.format(primary_key, name)
4243
msg = msg[:-1] # Remove last \n
4344
else:

0 commit comments

Comments
 (0)