Skip to content

Commit

Permalink
chore: loosen get_by_path annotation to Mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Dec 3, 2024
1 parent 3a6a2e2 commit 05e26e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ampel/util/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def try_int(key: str | int) -> str | int:


def get_by_path(
mapping: dict, path: str | int | Sequence[str | int], delimiter: str = '.'
mapping: Mapping, path: str | int | Sequence[str | int], delimiter: str = '.'
) -> None | UBson:
"""
Get an item from a nested mapping by path, e.g.
Expand All @@ -49,7 +49,7 @@ def get_by_path(
return mapping


def get_by_json_path(d: dict[str, Any], path: str | Sequence[str], delimiter: str = '.') -> None | tuple[str, UBson]:
def get_by_json_path(d: Mapping, path: str | Sequence[str], delimiter: str = '.') -> None | tuple[str, UBson]:
"""
Lacks robustness, unflexible, fast.
Supports only Bracket notation with number (https://cburgmer.github.io/json-path-comparison/)
Expand Down Expand Up @@ -94,7 +94,7 @@ def get_by_json_path(d: dict[str, Any], path: str | Sequence[str], delimiter: st


def set_by_path(
d: dict, path: str | Sequence[str], val: Any,
d: MutableMapping, path: str | Sequence[str], val: Any,
delimiter: str = '.', create: bool = True
) -> bool:
"""
Expand All @@ -117,7 +117,7 @@ def set_by_path(
return True


def del_by_path(d: dict, path: str | Sequence[str], delimiter: str = '.') -> bool:
def del_by_path(d: MutableMapping, path: str | Sequence[str], delimiter: str = '.') -> bool:
""" :returns: False if the key was successfully deleted, True otherwise """

if isinstance(path, str):
Expand Down

0 comments on commit 05e26e4

Please sign in to comment.