7 | 7 |
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
|
8 | 8 |
--- a/webargs/core.py
|
9 | 9 |
+++ b/webargs/core.py
|
10 | |
@@ -7,6 +7,7 @@ import inspect
|
|
10 |
@@ -6,6 +6,7 @@ import inspect
|
11 | 11 |
import logging
|
12 | 12 |
import warnings
|
13 | 13 |
from distutils.version import LooseVersion
|
14 | 14 |
+from packaging import version
|
15 | 15 |
|
16 | 16 |
try:
|
17 | |
import simplejson as json
|
18 | |
@@ -55,7 +56,7 @@ def get_func_args(func):
|
19 | |
return _signature(func.__call__)
|
|
17 |
from collections.abc import Mapping
|
|
18 |
@@ -35,7 +36,7 @@ __all__ = [
|
|
19 |
"parse_json",
|
|
20 |
]
|
20 | 21 |
|
21 | |
|
22 | |
-MARSHMALLOW_VERSION_INFO = tuple(LooseVersion(ma.__version__).version)
|
|
22 |
-MARSHMALLOW_VERSION_INFO = tuple(LooseVersion(ma.__version__).version) # type: tuple
|
23 | 23 |
+MARSHMALLOW_VERSION_INFO = ma.__version__
|
24 | 24 |
|
25 | |
DEFAULT_VALIDATION_STATUS = 422
|
|
25 |
DEFAULT_VALIDATION_STATUS = 422 # type: int
|
26 | 26 |
|
27 | |
@@ -142,7 +143,7 @@ def dict2schema(dct):
|
28 | |
`Fields <marshmallow.fields.Field>`.
|
29 | |
"""
|
|
27 |
@@ -57,7 +58,7 @@ def dict2schema(dct):
|
30 | 28 |
attrs = dct.copy()
|
31 | |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
32 | |
+ if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0"):
|
33 | 29 |
|
34 | |
class Meta(object):
|
|
30 |
class Meta(object):
|
|
31 |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
|
32 |
+ if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0"):
|
35 | 33 |
strict = True
|
36 | |
@@ -354,7 +355,7 @@ class Parser(object):
|
|
34 |
else:
|
|
35 |
register = False
|
|
36 |
@@ -265,7 +266,7 @@ class Parser(object):
|
37 | 37 |
argdict = schema.fields
|
38 | 38 |
parsed = {}
|
39 | 39 |
for argname, field_obj in iteritems(argdict):
|
|
42 | 42 |
parsed_value = self.parse_arg(argname, field_obj, req, locations)
|
43 | 43 |
# If load_from is specified on the field, try to parse from that key
|
44 | 44 |
if parsed_value is missing and field_obj.load_from:
|
45 | |
@@ -378,7 +379,7 @@ class Parser(object):
|
46 | |
# Raise a webargs error instead
|
47 | |
kwargs = getattr(error, "kwargs", {})
|
48 | |
kwargs["data"] = error.data
|
49 | |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
50 | |
+ if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b12"):
|
51 | |
kwargs["fields"] = error.fields
|
52 | |
kwargs["field_names"] = error.field_names
|
53 | |
else:
|
54 | |
@@ -432,7 +433,7 @@ class Parser(object):
|
|
45 |
@@ -309,7 +310,7 @@ class Parser(object):
|
55 | 46 |
schema = argmap(req)
|
56 | 47 |
else:
|
57 | 48 |
schema = dict2schema(argmap)()
|
|
60 | 51 |
warnings.warn(
|
61 | 52 |
"It is highly recommended that you set strict=True on your schema "
|
62 | 53 |
"so that the parser's error handler will be invoked when expected.",
|
63 | |
@@ -479,7 +480,7 @@ class Parser(object):
|
64 | |
try:
|
65 | |
parsed = self._parse_request(schema=schema, req=req, locations=locations)
|
|
54 |
@@ -355,7 +356,7 @@ class Parser(object):
|
|
55 |
schema=schema, req=req, locations=locations or self.locations
|
|
56 |
)
|
66 | 57 |
result = schema.load(parsed)
|
67 | 58 |
- data = result.data if MARSHMALLOW_VERSION_INFO[0] < 3 else result
|
68 | 59 |
+ data = result.data if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b7") else result
|