From b4f20073a69edb5600b45b6c1e411c7badb14367 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <a.schlemmer@indiscale.com> Date: Fri, 25 Oct 2024 10:07:01 +0200 Subject: [PATCH] doc(apiutils): Added type hints and a comprehensive docstring to describe_diff function --- src/linkahead/apiutils.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/linkahead/apiutils.py b/src/linkahead/apiutils.py index 4ae8edd1..450a316a 100644 --- a/src/linkahead/apiutils.py +++ b/src/linkahead/apiutils.py @@ -512,7 +512,36 @@ def merge_entities(entity_a: Entity, return entity_a -def describe_diff(olddiff, newdiff, name=None, as_update=True): +def describe_diff(olddiff: dict[str, Any], newdiff: dict[str, Any], + name: str=None, + as_update=True, + label_old="old version", + label_new="new version"): + """ + Generate a textual description of the differences between two entities. + These can be generated using :func:`compare_entities` and used within this function like this: + + `describe_diff(*compare_entities(...))` + + Arguments: + ---------- + + olddiff: dict[str, Any] + First element of the tuple output of :func:`compare_entities`. + This is referred to as the "old" version. + + newdiff: dict[str, Any] + Second element of the tuple output of :func:`compare_entities`. + This is referred to as the "new" version. + + + name: str + Default None. Name of the entity that will be shown in the output text. + + as_update: bool + Default True. Not used anymore. + + """ description = "" for attr in list(set(list(olddiff.keys()) + list(newdiff.keys()))): -- GitLab