openstack.format: Remove 'serialize' classmethod

This is not used anywhere. Drop it. A release note is included although
it likely isn't necessary since this will have no effect as again we
weren't using this.

Change-Id: I3878216a12a387c9c30fcbadad4da0019612fc5a
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-07-25 14:32:57 +01:00
parent f9bea72ac5
commit 3163c7597d
5 changed files with 5 additions and 35 deletions

View File

@ -12,11 +12,6 @@
class Formatter:
@classmethod
def serialize(cls, value):
"""Return a string representing the formatted value"""
raise NotImplementedError
@classmethod
def deserialize(cls, value):
"""Return a formatted object representing the value"""
@ -36,14 +31,3 @@ class BoolStr(Formatter):
raise ValueError(
"Unable to deserialize boolean string: %s" % value
)
@classmethod
def serialize(cls, value):
"""Convert a boolean to a boolean string"""
if isinstance(value, bool):
if value:
return "true"
else:
return "false"
else:
raise ValueError("Unable to serialize boolean string: %s" % value)

View File

@ -28,11 +28,3 @@ class HREFToUUID(format.Formatter):
# The UUID will be the last portion of the URI.
return parts.path.split("/")[-1]
@classmethod
def serialize(cls, value):
# NOTE(briancurtin): If we had access to the session to get
# the endpoint we could do something smart here like take an ID
# and give back an HREF, but this will just have to be something
# that works different because Barbican does what it does...
return value

View File

@ -27,10 +27,3 @@ class TestBoolStrFormatter(base.TestCase):
self.assertRaises(ValueError, format.BoolStr.deserialize, None)
self.assertRaises(ValueError, format.BoolStr.deserialize, '')
self.assertRaises(ValueError, format.BoolStr.deserialize, 'INVALID')
def test_serialize(self):
self.assertEqual('true', format.BoolStr.serialize(True))
self.assertEqual('false', format.BoolStr.serialize(False))
self.assertRaises(ValueError, format.BoolStr.serialize, None)
self.assertRaises(ValueError, format.BoolStr.serialize, '')
self.assertRaises(ValueError, format.BoolStr.serialize, 'True')

View File

@ -204,10 +204,6 @@ class TestComponent(base.TestCase):
class FakeFormatter(format.Formatter):
calls = []
@classmethod
def serialize(cls, arg):
FakeFormatter.calls.append(arg)
@classmethod
def deserialize(cls, arg):
FakeFormatter.calls.append(arg)

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
The ``openstack.format.Formatter`` class no longer defines a ``serialize``
method to override. This was unused and unneccessary complexity.