From 3163c7597df8334023742e0c0981b26f465a7181 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 25 Jul 2023 14:32:57 +0100 Subject: [PATCH] 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 --- openstack/format.py | 16 ---------------- openstack/key_manager/v1/_format.py | 8 -------- openstack/tests/unit/test_format.py | 7 ------- openstack/tests/unit/test_resource.py | 4 ---- ...p-formatter-deserialize-30b19956fb79bb8d.yaml | 5 +++++ 5 files changed, 5 insertions(+), 35 deletions(-) create mode 100644 releasenotes/notes/drop-formatter-deserialize-30b19956fb79bb8d.yaml diff --git a/openstack/format.py b/openstack/format.py index 3a750faad..b72c34f97 100644 --- a/openstack/format.py +++ b/openstack/format.py @@ -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) diff --git a/openstack/key_manager/v1/_format.py b/openstack/key_manager/v1/_format.py index 8da3515ac..58313c0a0 100644 --- a/openstack/key_manager/v1/_format.py +++ b/openstack/key_manager/v1/_format.py @@ -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 diff --git a/openstack/tests/unit/test_format.py b/openstack/tests/unit/test_format.py index 50b5b04da..532133502 100644 --- a/openstack/tests/unit/test_format.py +++ b/openstack/tests/unit/test_format.py @@ -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') diff --git a/openstack/tests/unit/test_resource.py b/openstack/tests/unit/test_resource.py index c05b6c4d4..7d09eda4b 100644 --- a/openstack/tests/unit/test_resource.py +++ b/openstack/tests/unit/test_resource.py @@ -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) diff --git a/releasenotes/notes/drop-formatter-deserialize-30b19956fb79bb8d.yaml b/releasenotes/notes/drop-formatter-deserialize-30b19956fb79bb8d.yaml new file mode 100644 index 000000000..d8415bf62 --- /dev/null +++ b/releasenotes/notes/drop-formatter-deserialize-30b19956fb79bb8d.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + The ``openstack.format.Formatter`` class no longer defines a ``serialize`` + method to override. This was unused and unneccessary complexity.