Formatting cleanup

This commit is contained in:
Jeremy Stretch 2024-02-20 09:22:56 -05:00
parent 5aa5b325df
commit dd22ebe5bc
5 changed files with 17 additions and 7 deletions

View File

@ -181,7 +181,11 @@ class Job(models.Model):
""" """
valid_statuses = JobStatusChoices.TERMINAL_STATE_CHOICES valid_statuses = JobStatusChoices.TERMINAL_STATE_CHOICES
if status not in valid_statuses: if status not in valid_statuses:
raise ValueError(_("Invalid status for job termination. Choices are: {choices}").format(choices=', '.join(valid_statuses))) raise ValueError(
_("Invalid status for job termination. Choices are: {choices}").format(
choices=', '.join(valid_statuses)
)
)
# Mark the job as completed # Mark the job as completed
self.status = status self.status = status

View File

@ -143,7 +143,8 @@ class ConditionSet:
logic = list(ruleset.keys())[0] logic = list(ruleset.keys())[0]
if type(logic) is not str or logic.lower() not in (AND, OR): if type(logic) is not str or logic.lower() not in (AND, OR):
raise ValueError(_("Invalid logic type: {logic} (must be '{op_and}' or '{op_or}')").format( raise ValueError(_("Invalid logic type: {logic} (must be '{op_and}' or '{op_or}')").format(
logic=logic, op_and=AND, op_or=OR)) logic=logic, op_and=AND, op_or=OR
))
self.logic = logic.lower() self.logic = logic.lower()
# Compile the set of Conditions # Compile the set of Conditions

View File

@ -34,7 +34,9 @@ class WritableNestedSerializer(BaseModelSerializer):
raise ValidationError( raise ValidationError(
_("Related object not found using the provided attributes: {params}").format(params=params)) _("Related object not found using the provided attributes: {params}").format(params=params))
except MultipleObjectsReturned: except MultipleObjectsReturned:
raise ValidationError(_("Multiple objects match the provided attributes: {params}").format(params=params)) raise ValidationError(
_("Multiple objects match the provided attributes: {params}").format(params=params)
)
except FieldError as e: except FieldError as e:
raise ValidationError(e) raise ValidationError(e)
@ -44,7 +46,10 @@ class WritableNestedSerializer(BaseModelSerializer):
pk = int(data) pk = int(data)
except (TypeError, ValueError): except (TypeError, ValueError):
raise ValidationError( raise ValidationError(
_("Related objects must be referenced by numeric ID or by dictionary of attributes. Received an unrecognized value: {value}").format(value=data) _(
"Related objects must be referenced by numeric ID or by dictionary of attributes. Received an "
"unrecognized value: {value}"
).format(value=data)
) )
# Look up object by PK # Look up object by PK

View File

@ -238,7 +238,7 @@ def parse_csv(reader):
if len(row) != len(headers): if len(row) != len(headers):
raise forms.ValidationError( raise forms.ValidationError(
_("Row {i}: Expected {count_expected} columns but found {count_found}").format( _("Row {i}: Expected {count_expected} columns but found {count_found}").format(
count_expected=len(headers), len_row=len(count_found) count_expected=len(headers), count_found=len(row)
) )
) )
row = [col.strip() for col in row] row = [col.strip() for col in row]

View File

@ -95,8 +95,8 @@ class ObjectPermissionRequiredMixin(AccessMixin):
if not hasattr(self, 'queryset'): if not hasattr(self, 'queryset'):
raise ImproperlyConfigured( raise ImproperlyConfigured(
_( _(
'{class_name} has no queryset defined. ObjectPermissionRequiredMixin may only be used on views which ' '{class_name} has no queryset defined. ObjectPermissionRequiredMixin may only be used on views '
'define a base queryset' 'which define a base queryset'
).format(class_name=self.__class__.__name__) ).format(class_name=self.__class__.__name__)
) )