From 67d17443898c0ce62d8d5af3f90c3b2294116aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Tue, 30 Apr 2024 10:45:51 +0200 Subject: [PATCH] Use format specifiers instead of percent format --- src/marshmallow_oneofschema/one_of_schema.py | 10 +++++----- tests/test_one_of_schema.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/marshmallow_oneofschema/one_of_schema.py b/src/marshmallow_oneofschema/one_of_schema.py index a6e3f96..71ea765 100644 --- a/src/marshmallow_oneofschema/one_of_schema.py +++ b/src/marshmallow_oneofschema/one_of_schema.py @@ -104,12 +104,12 @@ def _dump(self, obj, *, update_fields=True, **kwargs): if obj_type is None: return ( None, - {"_schema": "Unknown object class: %s" % obj.__class__.__name__}, + {"_schema": f"Unknown object class: {obj.__class__.__name__}"}, ) type_schema = self.type_schemas.get(obj_type) if not type_schema: - return None, {"_schema": "Unsupported object type: %s" % obj_type} + return None, {"_schema": f"Unsupported object type: {obj_type}"} schema = type_schema if isinstance(type_schema, Schema) else type_schema() @@ -156,7 +156,7 @@ def load(self, data, *, many=None, partial=None, unknown=None, **kwargs): def _load(self, data, *, partial=None, unknown=None, **kwargs): if not isinstance(data, dict): - raise ValidationError({"_schema": "Invalid data type: %s" % data}) + raise ValidationError({"_schema": f"Invalid data type: {data}"}) data = dict(data) unknown = unknown or self.unknown @@ -172,11 +172,11 @@ def _load(self, data, *, partial=None, unknown=None, **kwargs): except TypeError as error: # data_type could be unhashable raise ValidationError( - {self.type_field: ["Invalid value: %s" % data_type]} + {self.type_field: [f"Invalid value: {data_type}"]} ) from error if not type_schema: raise ValidationError( - {self.type_field: ["Unsupported value: %s" % data_type]} + {self.type_field: [f"Unsupported value: {data_type}"]} ) schema = type_schema if isinstance(type_schema, Schema) else type_schema() diff --git a/tests/test_one_of_schema.py b/tests/test_one_of_schema.py index e8d0528..fcd7f04 100644 --- a/tests/test_one_of_schema.py +++ b/tests/test_one_of_schema.py @@ -12,7 +12,7 @@ def __init__(self, value=None): self.value = value def __repr__(self): - return "" % self.value + return f"" def __eq__(self, other): return isinstance(other, self.__class__) and self.value == other.value @@ -31,7 +31,7 @@ def __init__(self, value=None): self.value = value def __repr__(self): - return "" % self.value + return f"" def __eq__(self, other): return isinstance(other, self.__class__) and self.value == other.value