Repository: marshmallow-code/marshmallow
Pull request #1446 (2019-11-03 17:38:35)

Chores: update pre-commit, autoupdate, fix types in validate


Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e8290d5a..5ce5e466 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,25 +1,25 @@
 repos:
 - repo: https://github.com/asottile/pyupgrade
-  rev: v1.24.0
+  rev: v1.25.1
   hooks:
   - id: pyupgrade
     args: ["--py3-plus"]
 - repo: https://github.com/python/black
-  rev: 19.3b0
+  rev: 19.10b0
   hooks:
   - id: black
     language_version: python3
 - repo: https://gitlab.com/pycqa/flake8
-  rev: 3.7.8
+  rev: 3.7.9
   hooks:
   - id: flake8
     additional_dependencies: ['flake8-bugbear==19.8.0']
 - repo: https://github.com/pre-commit/mirrors-mypy
-  rev: v0.730
+  rev: v0.740
   hooks:
   - id: mypy
 - repo: https://github.com/asottile/blacken-docs
   rev: v1.3.0
   hooks:
   - id: blacken-docs
-    additional_dependencies: [black==19.3b0]
+    additional_dependencies: [black==19.10b0]
diff --git a/pyproject.toml b/pyproject.toml
index a34de3d9..332d869f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,4 +1,3 @@
 [tool.black]
 line-length = 88
-# Uncomment when https://github.com/python/black/pull/763 is released
-# target-version = ['py35', 'py36', 'py37']
+target-version = ['py35', 'py36', 'py37', 'py38']
diff --git a/setup.py b/setup.py
index e1f7d75c..d72c1723 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ EXTRAS_REQUIRE = {
         "mypy==0.740",
         "flake8==3.7.9",
         "flake8-bugbear==19.8.0",
-        "pre-commit~=1.17",
+        "pre-commit~=1.20",
     ],
     "docs": [
         "sphinx==2.2.1",
diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py
index 3b444b18..edd85d88 100644
--- a/src/marshmallow/validate.py
+++ b/src/marshmallow/validate.py
@@ -16,6 +16,8 @@ class Validator:
         add a useful `__repr__` implementation for validators.
     """
 
+    error = None  # type: typing.Optional[str]
+
     def __repr__(self) -> str:
         args = self._repr_args()
         args = "{}, ".format(args) if args else ""
@@ -95,7 +97,7 @@ class URL(Validator):
         error: str = None
     ):
         self.relative = relative
-        self.error = error or self.default_message
+        self.error = error or self.default_message  # type: str
         self.schemes = schemes or self.default_schemes
         self.require_tld = require_tld
 
@@ -153,7 +155,7 @@ class Email(Validator):
     default_message = "Not a valid email address."
 
     def __init__(self, *, error: str = None):
-        self.error = error or self.default_message
+        self.error = error or self.default_message  # type: str
 
     def _format_error(self, value) -> typing.Any:
         return self.error.format(input=value)
@@ -336,7 +338,7 @@ class Equal(Validator):
 
     def __init__(self, comparable, *, error: str = None):
         self.comparable = comparable
-        self.error = error or self.default_message
+        self.error = error or self.default_message  # type: str
 
     def _repr_args(self) -> str:
         return "comparable={!r}".format(self.comparable)
@@ -377,7 +379,7 @@ class Regexp(Validator):
         self.regex = (
             re.compile(regex, flags) if isinstance(regex, (str, bytes)) else regex
         )
-        self.error = error or self.default_message
+        self.error = error or self.default_message  # type: str
 
     def _repr_args(self) -> str:
         return "regex={!r}".format(self.regex)
@@ -408,7 +410,7 @@ class Predicate(Validator):
 
     def __init__(self, method: str, *, error: str = None, **kwargs):
         self.method = method
-        self.error = error or self.default_message
+        self.error = error or self.default_message  # type: str
         self.kwargs = kwargs
 
     def _repr_args(self) -> str:
@@ -439,7 +441,7 @@ class NoneOf(Validator):
     def __init__(self, iterable: typing.Iterable, *, error: str = None):
         self.iterable = iterable
         self.values_text = ", ".join(str(each) for each in self.iterable)
-        self.error = error or self.default_message
+        self.error = error or self.default_message  # type: str
 
     def _repr_args(self) -> str:
         return "iterable={!r}".format(self.iterable)
@@ -479,7 +481,7 @@ class OneOf(Validator):
         self.choices_text = ", ".join(str(choice) for choice in self.choices)
         self.labels = labels if labels is not None else []
         self.labels_text = ", ".join(str(label) for label in self.labels)
-        self.error = error or self.default_message
+        self.error = error or self.default_message  # type: str
 
     def _repr_args(self) -> str:
         return "choices={!r}, labels={!r}".format(self.choices, self.labels)
diff --git a/tox.ini b/tox.ini
index 97d3912d..9c1cf2b7 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,7 +6,7 @@ extras = tests
 commands = pytest {posargs}
 
 [testenv:lint]
-deps = pre-commit~=1.17
+deps = pre-commit~=1.20
 skip_install = true
 commands = pre-commit run --all-files --show-diff-on-failure
 


Test patch:
diff --git a/tests/test_deserialization.py b/tests/test_deserialization.py
index f53bbb4a..e82df008 100644
--- a/tests/test_deserialization.py
+++ b/tests/test_deserialization.py
@@ -1010,7 +1010,7 @@ class TestFieldDeserialization:
             field.deserialize("invalid")
 
     def test_field_deserialization_with_user_validator_that_raises_error_with_list(
-        self
+        self,
     ):
         def validator(val):
             raise ValidationError(["err1", "err2"])
@@ -1258,7 +1258,7 @@ class TestSchemaDeserialization:
         assert load_data == {"bar": {"baz": 42}}
 
     def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name(
-        self
+        self,
     ):
         class AliasingUserSerializer(Schema):
             username = fields.Email(attribute="email")
@@ -1271,7 +1271,7 @@ class TestSchemaDeserialization:
         assert errors["username"] == ["Not a valid email address."]
 
     def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name(
-        self
+        self,
     ):
         class AliasingUserSerializer(Schema):
             name = fields.String(data_key="Name")
diff --git a/tests/test_fields.py b/tests/test_fields.py
index f4cb3bd2..846e1611 100644
--- a/tests/test_fields.py
+++ b/tests/test_fields.py
@@ -215,7 +215,7 @@ class TestErrorMessages:
     ]
 
     def test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg(
-        self
+        self,
     ):
         field = self.MyField()
         assert field.error_messages["custom"] == "Custom error message."
diff --git a/tests/test_serialization.py b/tests/test_serialization.py
index f88e28af..8c67e3f3 100644
--- a/tests/test_serialization.py
+++ b/tests/test_serialization.py
@@ -598,7 +598,7 @@ class TestFieldSerialization:
         assert len(result) == 2
 
     def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement(  # noqa: B950
-        self
+        self,
     ):
         def custom_generator():
             yield