Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add a docstring to _flatten_dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Feb 3, 2023
1 parent 8e9fc28 commit d5651e5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions synapse/push/bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,27 @@ def _flatten_dict(
prefix: Optional[List[str]] = None,
result: Optional[Dict[str, str]] = None,
) -> Dict[str, str]:
"""
Given a JSON dictionary (or event) which might contain sub dictionaries,
flatten it into a single layer dictionary by combining the keys & sub-keys.
Transforms:
{"foo": {"bar": "test"}}
To:
{"foo.bar": "test"}
Args:
d: The event or content to continue flattening.
room_version: The room version object.
prefix: The key prefix (from outer dictionaries).
result: The result to mutate.
Returns:
The resulting dictionary.
"""
if prefix is None:
prefix = []
if result is None:
Expand Down

0 comments on commit d5651e5

Please sign in to comment.