From 0e48d0cf715c355d9bb57b0eabc09b0127f47a65 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:11:41 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.13 → v0.4.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.13...v0.4.2) - [github.com/python-jsonschema/check-jsonschema: 0.27.3 → 0.28.2](https://github.com/python-jsonschema/check-jsonschema/compare/0.27.3...0.28.2) - [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.10.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.10.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cc4687b..ced73f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.13 + rev: v0.4.2 hooks: - id: ruff - id: ruff-format - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.27.3 + rev: 0.28.2 hooks: - id: check-github-workflows - repo: https://github.com/asottile/blacken-docs @@ -14,7 +14,7 @@ repos: - id: blacken-docs additional_dependencies: [black==23.12.1] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.10.0 hooks: - id: mypy additional_dependencies: ["marshmallow>=3,<4"] 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 2/2] 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