Skip to content

Commit

Permalink
Make patcher
Browse files Browse the repository at this point in the history
  • Loading branch information
nineteendo committed Aug 15, 2024
1 parent a836673 commit daba609
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 331 deletions.
7 changes: 5 additions & 2 deletions src/jsonyx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (C) 2024 Nice Zombies
"""jsonyx module for JSON (de)serialization."""
# TODO(Nice Zombies): add Patcher
from __future__ import annotations

__all__: list[str] = [
Expand Down Expand Up @@ -31,7 +32,7 @@

from jsonyx._decoder import DuplicateKey, JSONSyntaxError, make_scanner
from jsonyx._encoder import make_encoder
from jsonyx._patcher import patcher
from jsonyx._patcher import make_patcher
from jsonyx.allow import NOTHING

if TYPE_CHECKING:
Expand Down Expand Up @@ -370,6 +371,8 @@ def loads(
)


# TODO(Nice Zombies): move to Patcher
# TODO(Nice Zombies): rename to apply_patch
def patch(obj: Any, operations: dict[str, Any] | list[dict[str, Any]]) -> Any:
"""Patch a Python object with an operation or a list of operations.
Expand All @@ -384,7 +387,7 @@ def patch(obj: Any, operations: dict[str, Any] | list[dict[str, Any]]) -> Any:
if isinstance(operations, dict):
operations = [operations]

patcher(root, operations)
make_patcher()(root, operations)
return root[0]


Expand Down
1 change: 1 addition & 0 deletions src/jsonyx/_decoder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (C) 2024 Nice Zombies
"""JSON decoder."""
# TODO(Nice Zombies): add specification
from __future__ import annotations

__all__: list[str] = ["DuplicateKey", "JSONSyntaxError", "make_scanner"]
Expand Down
Loading

0 comments on commit daba609

Please sign in to comment.