Skip to content

Commit edf8700

Browse files
committed
Use new string formatting syntax
Python 2.5 support was dropped long ago to care about
1 parent 3ab6c5a commit edf8700

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

jsonpatch.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def _get_operation(self, operation):
367367
raise JsonPatchException("Operation must be a string")
368368

369369
if op not in self.operations:
370-
raise JsonPatchException("Unknown operation '%s'" % op)
370+
raise JsonPatchException("Unknown operation {0!r}".format(op))
371371

372372
cls = self.operations[op]
373373
return cls(operation)
@@ -434,7 +434,7 @@ def apply(self, obj):
434434
subobj[part] = value
435435

436436
else:
437-
raise TypeError("invalid document type %s" % (type(subobj),))
437+
raise TypeError("invalid document type {0}".format(type(subobj)))
438438

439439
return obj
440440

@@ -455,11 +455,10 @@ def apply(self, obj):
455455

456456
elif isinstance(subobj, dict):
457457
if not part in subobj:
458-
raise JsonPatchConflict("can't replace non-existent object '%s'"
459-
% part)
460-
458+
msg = "can't replace non-existent object '{0}'".format(part)
459+
raise JsonPatchConflict(msg)
461460
else:
462-
raise TypeError("invalid document type %s" % (type(subobj),))
461+
raise TypeError("invalid document type {0}".format(type(subobj)))
463462

464463
subobj[part] = value
465464
return obj
@@ -506,9 +505,9 @@ def apply(self, obj):
506505
if 'value' in self.operation:
507506
value = self.operation['value']
508507
if val != value:
509-
raise JsonPatchTestFailed(
510-
'%s is not equal to tested value %s (types %s and %s)'
511-
% (val, value, type(val), type(value)))
508+
msg = '{0} ({1}) is not equal to tested value {2} ({3})'
509+
raise JsonPatchTestFailed(msg.format(val, type(val),
510+
value, type(value)))
512511

513512
return obj
514513

0 commit comments

Comments
 (0)