Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #183

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
10 changes: 5 additions & 5 deletions src/marshmallow_oneofschema/one_of_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_one_of_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, value=None):
self.value = value

def __repr__(self):
return "<Foo value=%s>" % self.value
return f"<Foo value={self.value}>"

def __eq__(self, other):
return isinstance(other, self.__class__) and self.value == other.value
Expand All @@ -31,7 +31,7 @@ def __init__(self, value=None):
self.value = value

def __repr__(self):
return "<Bar value=%s>" % self.value
return f"<Bar value={self.value}>"

def __eq__(self, other):
return isinstance(other, self.__class__) and self.value == other.value
Expand Down
Loading