diff mbox series

[6/6] REST: Make single-use function a staticmethod

Message ID 20180110000526.27392-7-stephen@that.guru
State Accepted
Headers show
Series Random cleanups | expand

Commit Message

Stephen Finucane Jan. 10, 2018, 12:05 a.m. UTC
Signed-off-by: Stephen Finucane <stephen@that.guru>
---
 patchwork/api/patch.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py
index 1922cf5b..115feffa 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__)