Repository: marshmallow-code/marshmallow
Pull request #2162 (2023-08-06 21:11:38)

pre-commit autoupdate
Replaces  #2159. Fixes flake8 issues.


Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ae90c53a..cfadfb9b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
 repos:
 - repo: https://github.com/asottile/pyupgrade
-  rev: v3.9.0
+  rev: v3.10.1
   hooks:
   - id: pyupgrade
     args: [--py38-plus]
@@ -10,7 +10,7 @@ repos:
   - id: black
     language_version: python3
 - repo: https://github.com/pycqa/flake8
-  rev: 6.0.0
+  rev: 6.1.0
   hooks:
   - id: flake8
     additional_dependencies: [flake8-bugbear==22.12.6]


Test patch:
diff --git a/tests/test_deserialization.py b/tests/test_deserialization.py
index 29cab67b..4e4cfbd3 100644
--- a/tests/test_deserialization.py
+++ b/tests/test_deserialization.py
@@ -844,7 +844,7 @@ class TestFieldDeserialization:
         d = dt.date(2014, 8, 21)
         iso_date = d.isoformat()
         result = field.deserialize(iso_date)
-        assert type(result) == dt.date
+        assert type(result) is dt.date
         assert_date_equal(result, d)
 
     @pytest.mark.parametrize(
@@ -1398,7 +1398,7 @@ class TestFieldDeserialization:
         with pytest.raises(ValidationError) as excinfo:
             field.deserialize("invalid")
         assert excinfo.value.args[0][0] == "Invalid value."
-        assert type(excinfo.value) == ValidationError
+        assert type(excinfo.value) is ValidationError
 
     def test_field_deserialization_with_user_validator_class_that_returns_bool(self):
         class MyValidator:
@@ -1437,7 +1437,7 @@ class TestFieldDeserialization:
         field = fields.String(validate=lambda s: False)
         with pytest.raises(ValidationError) as excinfo:
             field.deserialize("привет")
-        assert type(excinfo.value) == ValidationError
+        assert type(excinfo.value) is ValidationError
 
     def test_field_deserialization_with_user_validators(self):
         validators_gen = (
@@ -1817,7 +1817,7 @@ class TestSchemaDeserialization:
             MySchema().load({"foo": "bar"})
         errors = excinfo.value.messages
 
-        assert type(errors["foo"]) == list
+        assert type(errors["foo"]) is list
         assert len(errors["foo"]) == 2
 
     def test_multiple_errors_can_be_stored_for_an_email_field(self):
diff --git a/tests/test_schema.py b/tests/test_schema.py
index bca3b78d..e92c0a30 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -188,19 +188,19 @@ def test_multiple_errors_can_be_stored_for_a_given_index():
 def test_dump_returns_a_dict(user):
     s = UserSchema()
     result = s.dump(user)
-    assert type(result) == dict
+    assert type(result) is dict
 
 
 def test_dumps_returns_a_string(user):
     s = UserSchema()
     result = s.dumps(user)
-    assert type(result) == str
+    assert type(result) is str
 
 
 def test_dumping_single_object_with_collection_schema(user):
     s = UserSchema(many=True)
     result = s.dump(user, many=False)
-    assert type(result) == dict
+    assert type(result) is dict
     assert result == UserSchema().dump(user)
 
 
@@ -208,7 +208,7 @@ def test_loading_single_object_with_collection_schema():
     s = UserSchema(many=True)
     in_data = {"name": "Mick", "email": "mick@stones.com"}
     result = s.load(in_data, many=False)
-    assert type(result) == User
+    assert type(result) is User
     assert result.name == UserSchema().load(in_data).name
 
 
@@ -224,15 +224,15 @@ def test_dumps_many():
 def test_load_returns_an_object():
     s = UserSchema()
     result = s.load({"name": "Monty"})
-    assert type(result) == User
+    assert type(result) is User
 
 
 def test_load_many():
     s = UserSchema()
     in_data = [{"name": "Mick"}, {"name": "Keith"}]
     result = s.load(in_data, many=True)
-    assert type(result) == list
-    assert type(result[0]) == User
+    assert type(result) is list
+    assert type(result[0]) is User
     assert result[0].name == "Mick"
 
 
@@ -300,7 +300,7 @@ def test_load_many_in_nested_empty_collection(val):
 def test_loads_returns_a_user():
     s = UserSchema()
     result = s.loads(json.dumps({"name": "Monty"}))
-    assert type(result) == User
+    assert type(result) is User
 
 
 def test_loads_many():
@@ -308,7 +308,7 @@ def test_loads_many():
     in_data = [{"name": "Mick"}, {"name": "Keith"}]
     in_json_data = json.dumps(in_data)
     result = s.loads(in_json_data, many=True)
-    assert type(result) == list
+    assert type(result) is list
     assert result[0].name == "Mick"
 
 
@@ -435,7 +435,7 @@ def test_dumps_returns_json(user):
     ser = UserSchema()
     serialized = ser.dump(user)
     json_data = ser.dumps(user)
-    assert type(json_data) == str
+    assert type(json_data) is str
     expected = json.dumps(serialized)
     assert json_data == expected
 
@@ -527,14 +527,14 @@ def test_stored_invalid_email():
 def test_integer_field():
     u = User("John", age=42.3)
     serialized = UserIntSchema().dump(u)
-    assert type(serialized["age"]) == int
+    assert type(serialized["age"]) is int
     assert serialized["age"] == 42
 
 
 def test_as_string():
     u = User("John", age=42.3)
     serialized = UserFloatStringSchema().dump(u)
-    assert type(serialized["age"]) == str
+    assert type(serialized["age"]) is str
     assert math.isclose(float(serialized["age"]), 42.3)
 
 
@@ -1619,22 +1619,22 @@ def test_meta_serializer_fields():
 def test_meta_fields_mapping(user):
     s = UserMetaSchema()
     s.dump(user)  # need to call dump to update fields
-    assert type(s.fields["balance"]) == fields.Decimal
+    assert type(s.fields["balance"]) is fields.Decimal
     # Inferred fields
-    assert type(s.fields["name"]._field_cache[fields.String]) == fields.String
-    assert type(s.fields["created"]._field_cache[fields.DateTime]) == fields.DateTime
-    assert type(s.fields["updated"]._field_cache[fields.DateTime]) == fields.DateTime
-    assert type(s.fields["age"]._field_cache[fields.Float]) == fields.Float
-    assert type(s.fields["registered"]._field_cache[fields.Boolean]) == fields.Boolean
-    assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) == fields.Raw
-    assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) == fields.Raw
-    assert type(s.fields["finger_count"]._field_cache[fields.Integer]) == fields.Integer
-    assert type(s.fields["uid"]._field_cache[fields.UUID]) == fields.UUID
-    assert type(s.fields["time_registered"]._field_cache[fields.Time]) == fields.Time
-    assert type(s.fields["birthdate"]._field_cache[fields.Date]) == fields.Date
+    assert type(s.fields["name"]._field_cache[fields.String]) is fields.String
+    assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime
+    assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime
+    assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float
+    assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean
+    assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw
+    assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw
+    assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer
+    assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID
+    assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time
+    assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date
     assert (
         type(s.fields["since_created"]._field_cache[fields.TimeDelta])
-        == fields.TimeDelta
+        is fields.TimeDelta
     )
 
 
@@ -2047,7 +2047,7 @@ class TestNestedSchema:
         data = BlogSchema().load(in_data)
         collabs = data["collaborators"]
         assert len(collabs) == 2
-        assert all(type(each) == User for each in collabs)
+        assert all(type(each) is User for each in collabs)
         assert collabs[0].name == in_data["collaborators"][0]["name"]
 
     def test_nested_errors(self):
diff --git a/tests/test_serialization.py b/tests/test_serialization.py
index b698d864..d274b28f 100644
--- a/tests/test_serialization.py
+++ b/tests/test_serialization.py
@@ -829,7 +829,7 @@ class TestFieldSerialization:
         obj = DateTimeList([dt.datetime.utcnow(), dt.datetime.now()])
         field = fields.List(fields.DateTime)
         result = field.serialize("dtimes", obj)
-        assert all(type(each) == str for each in result)
+        assert all(type(each) is str for each in result)
 
     def test_list_field_serialize_none_returns_none(self):
         obj = DateTimeList(None)
@@ -912,8 +912,8 @@ class TestFieldSerialization:
         obj = DateTimeIntegerTuple((dt.datetime.utcnow(), 42))
         field = fields.Tuple([fields.DateTime, fields.Integer])
         result = field.serialize("dtime_int", obj)
-        assert type(result[0]) == str
-        assert type(result[1]) == int
+        assert type(result[0]) is str
+        assert type(result[1]) is int
 
     def test_tuple_field_serialize_none_returns_none(self):
         obj = DateTimeIntegerTuple(None)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index e440ce26..390c0ab0 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -171,7 +171,7 @@ def test_isoformat(value, expected):
 )
 def test_from_rfc(value, expected):
     result = utils.from_rfc(value)
-    assert type(result) == dt.datetime
+    assert type(result) is dt.datetime
     assert result == expected
 
 
@@ -200,7 +200,7 @@ def test_from_rfc(value, expected):
 )
 def test_from_iso_datetime(value, expected):
     result = utils.from_iso_datetime(value)
-    assert type(result) == dt.datetime
+    assert type(result) is dt.datetime
     assert result == expected
 
 
@@ -208,7 +208,7 @@ def test_from_iso_time_with_microseconds():
     t = dt.time(1, 23, 45, 6789)
     formatted = t.isoformat()
     result = utils.from_iso_time(formatted)
-    assert type(result) == dt.time
+    assert type(result) is dt.time
     assert_time_equal(result, t)
 
 
@@ -216,7 +216,7 @@ def test_from_iso_time_without_microseconds():
     t = dt.time(1, 23, 45)
     formatted = t.isoformat()
     result = utils.from_iso_time(formatted)
-    assert type(result) == dt.time
+    assert type(result) is dt.time
     assert_time_equal(result, t)
 
 
@@ -224,7 +224,7 @@ def test_from_iso_date():
     d = dt.date(2014, 8, 21)
     iso_date = d.isoformat()
     result = utils.from_iso_date(iso_date)
-    assert type(result) == dt.date
+    assert type(result) is dt.date
     assert_date_equal(result, d)
 
 
@@ -237,7 +237,7 @@ def test_from_iso_date():
 )
 def test_from_timestamp(value, expected):
     result = utils.from_timestamp(value)
-    assert type(result) == dt.datetime
+    assert type(result) is dt.datetime
     assert result == expected