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 | |
@@ -30,9 +30,7 @@ __all__ = [
|
|
10 |
@@ -6,6 +6,7 @@ import functools
|
|
11 |
import inspect
|
|
12 |
import logging
|
|
13 |
import warnings
|
|
14 |
+from packaging import version
|
|
15 |
|
|
16 |
try:
|
|
17 |
import simplejson as json
|
|
18 |
@@ -30,9 +31,7 @@ __all__ = [
|
11 | 19 |
"parse_json",
|
12 | 20 |
]
|
13 | 21 |
|
|
18 | 26 |
|
19 | 27 |
DEFAULT_VALIDATION_STATUS = 422
|
20 | 28 |
|
21 | |
@@ -98,7 +96,7 @@ def argmap2schema(argmap):
|
|
29 |
@@ -98,7 +97,7 @@ def argmap2schema(argmap):
|
22 | 30 |
names to `Fields <marshmallow.fields.Field>`.
|
23 | 31 |
"""
|
24 | 32 |
attrs = argmap.copy()
|
25 | 33 |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
26 | |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b7":
|
|
34 |
+ if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b7"):
|
27 | 35 |
|
28 | 36 |
class Meta(object):
|
29 | 37 |
strict = True
|
30 | |
@@ -302,7 +300,7 @@ class Parser(object):
|
|
38 |
@@ -302,7 +301,7 @@ class Parser(object):
|
31 | 39 |
argdict = schema.fields
|
32 | 40 |
parsed = {}
|
33 | 41 |
for argname, field_obj in iteritems(argdict):
|
34 | 42 |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
35 | |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b8":
|
|
43 |
+ if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b8"):
|
36 | 44 |
parsed_value = self.parse_arg(argname, field_obj, req, locations)
|
37 | 45 |
# If load_from is specified on the field, try to parse from that key
|
38 | 46 |
if parsed_value is missing and field_obj.load_from:
|
39 | |
@@ -325,7 +323,7 @@ class Parser(object):
|
|
47 |
@@ -325,7 +324,7 @@ class Parser(object):
|
40 | 48 |
kwargs = getattr(error, "kwargs", {})
|
41 | 49 |
kwargs["field_names"] = error.field_names
|
42 | 50 |
kwargs["data"] = error.data
|
43 | 51 |
- if MARSHMALLOW_VERSION_INFO[0] < 3:
|
44 | |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b12":
|
|
52 |
+ if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b12"):
|
45 | 53 |
kwargs["fields"] = error.fields
|
46 | 54 |
if "status_code" not in kwargs:
|
47 | 55 |
kwargs["status_code"] = self.DEFAULT_VALIDATION_STATUS
|
48 | |
@@ -358,7 +356,7 @@ class Parser(object):
|
|
56 |
@@ -358,7 +357,7 @@ class Parser(object):
|
49 | 57 |
schema = argmap(req)
|
50 | 58 |
else:
|
51 | 59 |
schema = argmap2schema(argmap)()
|
52 | 60 |
- if MARSHMALLOW_VERSION_INFO[0] < 3 and not schema.strict:
|
53 | |
+ if MARSHMALLOW_VERSION_INFO < "3.0.0b7" and not schema.strict:
|
|
61 |
+ if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b7") and not schema.strict:
|
54 | 62 |
warnings.warn(
|
55 | 63 |
"It is highly recommended that you set strict=True on your schema "
|
56 | 64 |
"so that the parser's error handler will be invoked when expected.",
|
57 | |
@@ -390,7 +388,7 @@ class Parser(object):
|
|
65 |
@@ -390,7 +389,7 @@ class Parser(object):
|
58 | 66 |
try:
|
59 | 67 |
parsed = self._parse_request(schema=schema, req=req, locations=locations)
|
60 | 68 |
result = schema.load(parsed)
|
61 | 69 |
- data = result.data if MARSHMALLOW_VERSION_INFO[0] < 3 else result
|
62 | |
+ data = result.data if MARSHMALLOW_VERSION_INFO < "3.0.0b7" else result
|
|
70 |
+ data = result.data if version.parse(MARSHMALLOW_VERSION_INFO) < version.parse("3.0.0b7") else result
|
63 | 71 |
self._validate_arguments(data, validators)
|
64 | 72 |
except ma.exceptions.ValidationError as error:
|
65 | 73 |
self._on_validation_error(error, req, schema)
|