@@ -92,7 +92,7 @@ def new(obj: Dict, path: str, value, separator="/", creator: Creator = None) ->
9292 return segments .set (obj , split_segments , value )
9393
9494
95- def delete (obj : Dict , glob : str , separator = '/' , afilter : Filter = None ) -> int :
95+ def delete (obj : Dict , glob : str , separator = "/" , afilter : Filter = None ) -> int :
9696 """
9797 Given a obj, delete all elements that match the glob.
9898
@@ -144,12 +144,12 @@ def f(obj, pair, counter):
144144
145145 [deleted ] = segments .foldm (obj , f , [0 ])
146146 if not deleted :
147- raise PathNotFound ("Could not find {0 } to delete it" . format ( glob ) )
147+ raise PathNotFound (f "Could not find { glob } to delete it" )
148148
149149 return deleted
150150
151151
152- def set (obj : Dict , glob : str , value , separator = '/' , afilter : Filter = None ) -> int :
152+ def set (obj : Dict , glob : str , value , separator = "/" , afilter : Filter = None ) -> int :
153153 """
154154 Given a path glob, set all existing elements in the document
155155 to the given value. Returns the number of elements changed.
@@ -205,12 +205,12 @@ def f(_, pair, results):
205205
206206 raise KeyError (glob )
207207 elif len (results ) > 1 :
208- raise ValueError ("dpath.util.get() globs must match only one leaf : %s" % glob )
208+ raise ValueError (f "dpath.util.get() globs must match only one leaf: { glob } " )
209209
210210 return results [0 ]
211211
212212
213- def values (obj : Dict , glob : str , separator = '/' , afilter : Filter = None , dirs = True ):
213+ def values (obj : Dict , glob : str , separator = "/" , afilter : Filter = None , dirs = True ):
214214 """
215215 Given an object and a path glob, return an array of all values which match
216216 the glob. The arguments to this function are identical to those of search().
@@ -220,7 +220,7 @@ def values(obj: Dict, glob: str, separator='/', afilter: Filter = None, dirs=Tru
220220 return [v for p , v in search (obj , glob , yielded , separator , afilter , dirs )]
221221
222222
223- def search (obj : Dict , glob : str , yielded = False , separator = '/' , afilter : Filter = None , dirs = True ):
223+ def search (obj : Dict , glob : str , yielded = False , separator = "/" , afilter : Filter = None , dirs = True ):
224224 """
225225 Given a path glob, return a dictionary containing all keys
226226 that matched the given glob.
@@ -249,7 +249,7 @@ def keeper(path, found):
249249 def yielder ():
250250 for path , found in segments .walk (obj ):
251251 if keeper (path , found ):
252- yield ( separator .join (map (segments .int_str , path )), found )
252+ yield separator .join (map (segments .int_str , path )), found
253253 return yielder ()
254254 else :
255255 def f (obj , pair , result ):
@@ -261,7 +261,7 @@ def f(obj, pair, result):
261261 return segments .fold (obj , f , {})
262262
263263
264- def merge (dst : Dict , src : Dict , separator = '/' , afilter : Filter = None , flags = MergeType .ADDITIVE ):
264+ def merge (dst : Dict , src : Dict , separator = "/" , afilter : Filter = None , flags = MergeType .ADDITIVE ):
265265 """
266266 Merge source into destination. Like dict.update() but performs deep
267267 merging.
@@ -311,7 +311,7 @@ def merger(dst, src, _segments=()):
311311 if len (key ) == 0 and not options .ALLOW_EMPTY_STRING_KEYS :
312312 raise InvalidKeyName ("Empty string keys not allowed without "
313313 "dpath.options.ALLOW_EMPTY_STRING_KEYS=True: "
314- "{}" . format ( current_path ) )
314+ f" { current_path } " )
315315
316316 # Validate src and dst types match.
317317 if flags & MergeType .TYPESAFE :
@@ -321,9 +321,7 @@ def merger(dst, src, _segments=()):
321321 ft = type (found )
322322 if tt != ft :
323323 path = separator .join (current_path )
324- raise TypeError ("Cannot merge objects of type"
325- "{0} and {1} at {2}"
326- "" .format (tt , ft , path ))
324+ raise TypeError (f"Cannot merge objects of type { tt } and { ft } at { path } " )
327325
328326 # Path not present in destination, create it.
329327 if not segments .has (dst , current_path ):
@@ -357,7 +355,7 @@ def merger(dst, src, _segments=()):
357355
358356 if flags & MergeType .REPLACE :
359357 try :
360- target ['' ]
358+ target ["" ]
361359 except TypeError :
362360 segments .set (dst , current_path , found )
363361 continue
0 commit comments