Skip to content

Commit 0c1dd99

Browse files
lafrechsloria
andauthored
Update pre-commit deps (#2840)
* Remove unused DummyModel from tests/base.py * pre-commit autoupdate * "Fix" ruff errors by with noqa * Ignore mypy error in tests * Ignore mypy false positive * Update black --------- Co-authored-by: Steven Loria <sloria1@gmail.com>
1 parent 7266de0 commit 0c1dd99

8 files changed

Lines changed: 18 additions & 28 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ ci:
22
autoupdate_schedule: monthly
33
repos:
44
- repo: https://github.com/astral-sh/ruff-pre-commit
5-
rev: v0.11.8
5+
rev: v0.12.5
66
hooks:
7-
- id: ruff
7+
- id: ruff-check
88
- id: ruff-format
99
- repo: https://github.com/python-jsonschema/check-jsonschema
10-
rev: 0.33.0
10+
rev: 0.33.2
1111
hooks:
1212
- id: check-github-workflows
1313
- id: check-readthedocs
@@ -16,4 +16,4 @@ repos:
1616
rev: 1.19.1
1717
hooks:
1818
- id: blacken-docs
19-
additional_dependencies: [black==24.10.0]
19+
additional_dependencies: [black==25.1.0]

src/marshmallow/fields.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ruff: noqa: F841, SLF001
1+
# ruff: noqa: SLF001
22
from __future__ import annotations
33

44
import abc
@@ -530,7 +530,7 @@ def schema(self) -> Schema:
530530
else:
531531
nested = typing.cast("Schema", self.nested)
532532
# defer the import of `marshmallow.schema` to avoid circular imports
533-
from marshmallow.schema import Schema
533+
from marshmallow.schema import Schema # noqa: PLC0415
534534

535535
if isinstance(nested, dict):
536536
nested = Schema.from_dict(nested)
@@ -558,7 +558,7 @@ def schema(self) -> Schema:
558558
f"`Schema`, not {nested.__class__}."
559559
)
560560
else:
561-
schema_class = class_registry.get_class(nested, all=False)
561+
schema_class = class_registry.get_class(nested, all=False) # type: ignore[unreachable]
562562
self._schema = schema_class(
563563
many=self.many,
564564
only=self.only,
@@ -591,7 +591,9 @@ def _test_collection(self, value: typing.Any) -> None:
591591
raise self.make_error("type", input=value, type=value.__class__.__name__)
592592

593593
def _load(
594-
self, value: typing.Any, partial: bool | types.StrSequenceOrSet | None = None
594+
self,
595+
value: typing.Any,
596+
partial: bool | types.StrSequenceOrSet | None = None, # noqa: FBT001
595597
):
596598
try:
597599
valid_data = self.schema.load(value, unknown=self.unknown, partial=partial)
@@ -606,7 +608,7 @@ def _deserialize(
606608
value: typing.Any,
607609
attr: str | None,
608610
data: typing.Mapping[str, typing.Any] | None,
609-
partial: bool | types.StrSequenceOrSet | None = None,
611+
partial: bool | types.StrSequenceOrSet | None = None, # noqa: FBT001
610612
**kwargs,
611613
):
612614
"""Same as :meth:`Field._deserialize` with additional ``partial`` argument.

src/marshmallow/orderedset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from collections.abc import MutableSet
2424

2525

26-
class OrderedSet(MutableSet):
26+
class OrderedSet(MutableSet): # noqa: PLW1641
2727
def __init__(self, iterable=None):
2828
self.end = end = []
2929
end += [None, end, end] # sentinel node for doubly linked list

src/marshmallow/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Utility methods for marshmallow."""
22

3-
# ruff: noqa: T201, T203
43
from __future__ import annotations
54

65
import datetime as dt

tests/base.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,6 @@ def __contains__(self, item):
161161
return item.name in [each.name for each in self.collaborators]
162162

163163

164-
class DummyModel:
165-
def __init__(self, foo):
166-
self.foo = foo
167-
168-
def __eq__(self, other):
169-
return self.foo == other.foo
170-
171-
def __str__(self):
172-
return f"bar {self.foo}"
173-
174-
175164
###### Schemas #####
176165

177166

tests/test_decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def overridden(self, item, **kwargs):
234234
item["overridden"] = "overridden"
235235
return item
236236

237-
deleted = None
237+
deleted = None # type: ignore[assignment]
238238

239239
parent_dumped = ParentSchema().dump({})
240240
assert parent_dumped == {

tests/test_registry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class FooSerializer(Schema):
189189

190190
def test_multiple_classes_with_same_name_raises_error():
191191
# Import a class with the same name
192-
from .foo_serializer import FooSerializer as FooSerializer1 # noqa: F401
192+
from .foo_serializer import FooSerializer as FooSerializer1 # noqa: PLC0415, F401
193193

194194
class MySchema(Schema):
195195
foo = fields.Nested("FooSerializer")
@@ -204,14 +204,14 @@ class MySchema(Schema):
204204

205205
def test_multiple_classes_with_all():
206206
# Import a class with the same name
207-
from .foo_serializer import FooSerializer as FooSerializer1 # noqa: F401
207+
from .foo_serializer import FooSerializer as FooSerializer1 # noqa: PLC0415, F401
208208

209209
classes = class_registry.get_class("FooSerializer", all=True)
210210
assert len(classes) == 2
211211

212212

213213
def test_can_use_full_module_path_to_class():
214-
from .foo_serializer import FooSerializer as FooSerializer1 # noqa: F401
214+
from .foo_serializer import FooSerializer as FooSerializer1 # noqa: PLC0415, F401
215215

216216
# Using full paths is ok
217217

tests/test_serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def test_dict_field_serialize_ordereddict(self, user):
438438
)
439439

440440
def test_structured_dict_value_serialize(self, user):
441-
user.various_data = {"foo": decimal.Decimal("1")}
441+
user.various_data = {"foo": decimal.Decimal(1)}
442442
field = fields.Dict(values=fields.Decimal)
443443
assert field.serialize("various_data", user) == {"foo": 1}
444444

@@ -448,7 +448,7 @@ def test_structured_dict_key_serialize(self, user):
448448
assert field.serialize("various_data", user) == {"1": "bar"}
449449

450450
def test_structured_dict_key_value_serialize(self, user):
451-
user.various_data = {1: decimal.Decimal("1")}
451+
user.various_data = {1: decimal.Decimal(1)}
452452
field = fields.Dict(keys=fields.Str, values=fields.Decimal)
453453
assert field.serialize("various_data", user) == {"1": 1}
454454

0 commit comments

Comments
 (0)