From ba7b56842d2443c57c8648532611a9e2bbccb4fb Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Sat, 6 Jan 2018 22:43:56 +0000 Subject: REST: Make single-use function a staticmethod Signed-off-by: Stephen Finucane --- patchwork/api/patch.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index 1922cf5..115feff 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -38,10 +38,6 @@ from patchwork.models import State from patchwork.parser import clean_subject -def format_state_name(state): - return ' '.join(state.split('-')) - - class StateField(RelatedField): """Avoid the need for a state endpoint. @@ -58,13 +54,17 @@ class StateField(RelatedField): '{data_type}.'), } + @staticmethod + def format_state_name(state): + return ' '.join(state.split('-')) + def to_internal_value(self, data): try: - data = format_state_name(data) + data = self.format_state_name(data) return self.get_queryset().get(name__iexact=data) except State.DoesNotExist: self.fail('invalid_choice', name=data, choices=', '.join([ - format_state_name(x.name) for x in self.get_queryset()])) + self.format_state_name(x.name) for x in self.get_queryset()])) except (TypeError, ValueError): self.fail('incorrect_type', data_type=type(data).__name__) -- cgit v1.2.3