Skip to content

Commit

Permalink
Fix type signature of _get_private_objects
Browse files Browse the repository at this point in the history
  • Loading branch information
lucc committed Dec 16, 2024
1 parent f6b7c5c commit f42dd91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions khard/carddav_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions test/test_yaml_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]})

0 comments on commit f42dd91

Please sign in to comment.