77from abc import ABC
88from abc import abstractmethod
99from io import IOBase
10+ from typing import Any
1011from typing import Dict
1112from typing import Iterable
1213from typing import List
@@ -74,7 +75,7 @@ def apply(
7475 else :
7576 parent .insert (int (target ), self .value )
7677 elif isinstance (parent , MutableMapping ):
77- parent [target ] = self .value
78+ parent [str ( target ) ] = self .value
7879 else :
7980 raise JSONPatchError (
8081 f"unexpected operation on { parent .__class__ .__name__ !r} "
@@ -183,7 +184,7 @@ def apply(
183184 elif isinstance (parent , MutableMapping ):
184185 if obj is UNDEFINED :
185186 raise JSONPatchError ("can't remove nonexistent property" )
186- del parent [self .path .parts [- 1 ]]
187+ del parent [str ( self .path .parts [- 1 ]) ]
187188 else :
188189 raise JSONPatchError (
189190 f"unexpected operation on { parent .__class__ .__name__ !r} "
@@ -221,7 +222,7 @@ def apply(
221222 elif isinstance (parent , MutableMapping ):
222223 if obj is UNDEFINED :
223224 raise JSONPatchError ("can't replace nonexistent property" )
224- parent [self .path .parts [- 1 ]] = self .value
225+ parent [str ( self .path .parts [- 1 ]) ] = self .value
225226 else :
226227 raise JSONPatchError (
227228 f"unexpected operation on { parent .__class__ .__name__ !r} "
@@ -259,7 +260,7 @@ def apply(
259260 if isinstance (source_parent , MutableSequence ):
260261 del source_parent [int (self .source .parts [- 1 ])]
261262 if isinstance (source_parent , MutableMapping ):
262- del source_parent [self .source .parts [- 1 ]]
263+ del source_parent [str ( self .source .parts [- 1 ]) ]
263264
264265 dest_parent , _ = self .dest .resolve_parent (data )
265266
@@ -270,7 +271,7 @@ def apply(
270271 if isinstance (dest_parent , MutableSequence ):
271272 dest_parent .insert (int (self .dest .parts [- 1 ]), source_obj )
272273 elif isinstance (dest_parent , MutableMapping ):
273- dest_parent [self .dest .parts [- 1 ]] = source_obj
274+ dest_parent [str ( self .dest .parts [- 1 ]) ] = source_obj
274275 else :
275276 raise JSONPatchError (
276277 f"unexpected operation on { dest_parent .__class__ .__name__ !r} "
@@ -312,7 +313,7 @@ def apply(
312313 if isinstance (dest_parent , MutableSequence ):
313314 dest_parent .insert (int (self .dest .parts [- 1 ]), copy .deepcopy (source_obj ))
314315 elif isinstance (dest_parent , MutableMapping ):
315- dest_parent [self .dest .parts [- 1 ]] = copy .deepcopy (source_obj )
316+ dest_parent [str ( self .dest .parts [- 1 ]) ] = copy .deepcopy (source_obj )
316317 else :
317318 raise JSONPatchError (
318319 f"unexpected operation on { dest_parent .__class__ .__name__ !r} "
@@ -628,7 +629,7 @@ def test(self: Self, path: Union[str, JSONPointer], value: object) -> Self:
628629
629630 def apply (
630631 self ,
631- data : Union [str , IOBase , MutableSequence [object ], MutableMapping [str , object ]],
632+ data : Union [str , IOBase , MutableSequence [object ], MutableMapping [str , Any ]],
632633 ) -> object :
633634 """Apply all operations from this patch to _data_.
634635
@@ -676,7 +677,7 @@ def asdicts(self) -> List[Dict[str, object]]:
676677
677678def apply (
678679 patch : Union [str , IOBase , Iterable [Mapping [str , object ]], None ],
679- data : Union [str , IOBase , MutableSequence [object ], MutableMapping [str , object ]],
680+ data : Union [str , IOBase , MutableSequence [object ], MutableMapping [str , Any ]],
680681 * ,
681682 unicode_escape : bool = True ,
682683 uri_decode : bool = False ,
0 commit comments