From f42dd919e47931d16cd0e9c5448315d91ca977e1 Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Mon, 16 Dec 2024 10:49:15 +0100 Subject: [PATCH] Fix type signature of _get_private_objects --- khard/carddav_object.py | 4 ++-- test/test_yaml_editable.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/khard/carddav_object.py b/khard/carddav_object.py index 4c70160..67cb979 100644 --- a/khard/carddav_object.py +++ b/khard/carddav_object.py @@ -906,9 +906,9 @@ def __init__(self, vcard: vobject.base.Component, # getters and setters ##################### - def _get_private_objects(self) -> Dict[str, List[str]]: + def _get_private_objects(self) -> Dict[str, List[Union[str, Dict[str, str]]]]: supported = [x.lower() for x in self.supported_private_objects] - private_objects: Dict[str, List[str]] = {} + private_objects: Dict[str, List[Union[str, Dict[str, str]]]] = {} for child in self.vcard.getChildren(): lower = child.name.lower() if lower.startswith("x-") and lower[2:] in supported: diff --git a/test/test_yaml_editable.py b/test/test_yaml_editable.py index 896b0da..39fc56e 100644 --- a/test/test_yaml_editable.py +++ b/test/test_yaml_editable.py @@ -83,3 +83,15 @@ def test_unsupported_private_objects_can_be_added_but_not_retrieved(self) -> Non ye._add_private_object("bar", "foo") self.assertEqual(ye._get_private_objects(), {"foo": ["bar"]}) self.assertIn("X-BAR:foo", ye.vcard.serialize()) + + def test_private_objects_can_have_an_ablabel(self) -> None: + ye = TestYAMLEditable() + ye.supported_private_objects = ["foo"] + foo = ye.vcard.add("X-FOO") + foo.value = "bar" + foo.group = "1" + label = ye.vcard.add("X-ABLABEL") + label.value = "baz" + label.group = "1" + result = ye._get_private_objects() + self.assertEqual(result, {"foo": [{"baz": "bar"}]})