File: remove_six.patch

package info (click to toggle)
flask-restful 0.3.10-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,312 kB
  • sloc: python: 3,945; makefile: 277; pascal: 26; sh: 20
file content (225 lines) | stat: -rw-r--r-- 7,261 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -276,5 +276,4 @@
   'flask': ('/usr/share/doc/python-flask-doc/html', None),
   'werkzeug': ('/usr/share/doc/python-werkzeug-doc/html', None),
   'python': ('/usr/share/doc/python3-doc/html', None),
-  'six': ('/usr/share/doc/python-six-doc/html', None),
 }
--- a/flask_restful/fields.py
+++ b/flask_restful/fields.py
@@ -1,7 +1,6 @@
 from calendar import timegm
 from decimal import Decimal as MyDecimal, ROUND_HALF_EVEN
 from email.utils import formatdate
-import six
 try:
     from urlparse import urlparse, urlunparse
 except ImportError:
@@ -23,7 +22,7 @@
     def __init__(self, underlying_exception):
         # just put the contextual representation of the error to hint on what
         # went wrong without exposing internals
-        super(MarshallingException, self).__init__(six.text_type(underlying_exception))
+        super(MarshallingException, self).__init__(str(underlying_exception))
 
 
 def is_indexable_but_not_string(obj):
@@ -210,7 +209,7 @@
     """
     def format(self, value):
         try:
-            return six.text_type(value)
+            return str(value)
         except ValueError as ve:
             raise MarshallingException(ve)
 
@@ -268,7 +267,7 @@
         values from the response.
         """
         super(FormattedString, self).__init__()
-        self.src_str = six.text_type(src_str)
+        self.src_str = str(src_str)
 
     def output(self, key, obj):
         try:
@@ -331,7 +330,7 @@
     """
 
     def format(self, value):
-        return six.text_type(MyDecimal(value))
+        return str(MyDecimal(value))
 
 
 class DateTime(Raw):
@@ -379,7 +378,7 @@
         dvalue = MyDecimal(value)
         if not dvalue.is_normal() and dvalue != ZERO:
             raise MarshallingException('Invalid Fixed precision number.')
-        return six.text_type(dvalue.quantize(self.precision, rounding=ROUND_HALF_EVEN))
+        return str(dvalue.quantize(self.precision, rounding=ROUND_HALF_EVEN))
 
 
 """Alias for :class:`~fields.Fixed`"""
--- a/flask_restful/reqparse.py
+++ b/flask_restful/reqparse.py
@@ -9,7 +9,6 @@
 from werkzeug import exceptions
 import flask_restful
 import decimal
-import six
 
 
 class Namespace(dict):
@@ -33,7 +32,6 @@
     u'files': u'an uploaded file',
 }
 
-text_type = lambda x: six.text_type(x)
 
 
 class Argument(object):
@@ -72,7 +70,7 @@
     """
 
     def __init__(self, name, default=None, dest=None, required=False,
-                 ignore=False, type=text_type, location=('json', 'values',),
+                 ignore=False, type=str, location=('json', 'values',),
                  choices=(), action='store', help=None, operators=('=',),
                  case_sensitive=True, store_missing=True, trim=False,
                  nullable=True):
@@ -113,7 +111,7 @@
         """Pulls values off the request in the provided location
         :param request: The flask request object to parse arguments from
         """
-        if isinstance(self.location, six.string_types):
+        if isinstance(self.location, str):
             value = getattr(request, self.location, MultiDict())
             if callable(value):
                 value = value()
@@ -164,7 +162,7 @@
             dict with the name of the argument and the error message to be
             bundled
         """
-        error_str = six.text_type(error)
+        error_str = str(error)
         error_msg = self.help.format(error_msg=error_str) if self.help else error_str
         msg = {self.name: error_msg}
 
@@ -231,7 +229,7 @@
                     results.append(value)
 
         if not results and self.required:
-            if isinstance(self.location, six.string_types):
+            if isinstance(self.location, str):
                 error_msg = u"Missing required parameter in {0}".format(
                     _friendly_location.get(self.location, self.location)
                 )
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,6 @@
 requirements = [
     'aniso8601>=0.82',
     'Flask>=0.8',
-    'six>=1.3.0',
     'pytz',
 ]
 
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -17,7 +17,6 @@
 from flask_restful import OrderedDict
 from json import dumps, loads, JSONEncoder
 from tests import assert_equal
-import six
 from types import SimpleNamespace
 from unittest.mock import patch
 
@@ -723,7 +722,7 @@
         app = Flask(__name__)
 
         def text(data, code, headers=None):
-            return flask.make_response(six.text_type(data))
+            return flask.make_response(str(data))
 
         class Foo(flask_restful.Resource):
 
--- a/tests/test_inputs.py
+++ b/tests/test_inputs.py
@@ -5,7 +5,6 @@
 
 #noinspection PyUnresolvedReferences
 from pytest import raises
-import six
 
 from flask_restful import inputs
 from tests import assert_equal
@@ -63,7 +62,7 @@
         inputs.url(value)
         assert False, "shouldn't get here"
     except ValueError as e:
-        assert_equal(six.text_type(e), u"{0} is not a valid URL".format(value))
+        assert_equal(str(e), u"{0} is not a valid URL".format(value))
 
 
 def test_bad_urls():
@@ -105,7 +104,7 @@
         inputs.url(value)
         assert False, u"inputs.url({0}) should raise an exception".format(value)
     except ValueError as e:
-        assert_equal(six.text_type(e),
+        assert_equal(str(e),
                      (u"{0} is not a valid URL. Did you mean: http://{0}".format(value)))
 
 
--- a/tests/test_reqparse.py
+++ b/tests/test_reqparse.py
@@ -6,9 +6,8 @@
 from werkzeug.wrappers import Request
 from werkzeug.datastructures import FileStorage, MultiDict
 from flask_restful.reqparse import Argument, RequestParser, Namespace
-import six
 import decimal
-
+import io
 import json
 
 
@@ -139,13 +138,6 @@
         self.assertEqual(arg.operators[0], "=")
         self.assertEqual(len(arg.operators), 1)
 
-    @patch('flask_restful.reqparse.six')
-    def test_default_type(self, mock_six):
-        arg = Argument("foo")
-        sentinel = object()
-        arg.type(sentinel)
-        mock_six.text_type.assert_called_with(sentinel)
-
     def test_default_default(self):
         arg = Argument("foo")
         self.assertEqual(arg.default, None)
@@ -671,9 +663,9 @@
         parser = RequestParser()
         parser.add_argument("foo", type=FileStorage, location='files')
 
-        fdata = six.b('foo bar baz qux')
+        fdata = b'foo bar baz qux'
         with app.test_request_context('/bubble', method='POST',
-                                      data={'foo': (six.BytesIO(fdata), 'baz.txt')}):
+                                      data={'foo': (io.BytesIO(fdata), 'baz.txt')}):
             args = parser.parse_args()
 
             self.assertEqual(args['foo'].name, 'foo')
@@ -691,9 +683,9 @@
         parser = RequestParser()
         parser.add_argument("foo", type=_custom_type, location='files')
 
-        fdata = six.b('foo bar baz qux')
+        fdata = b'foo bar baz qux'
         with app.test_request_context('/bubble', method='POST',
-                                      data={'foo': (six.BytesIO(fdata), 'baz.txt')}):
+                                      data={'foo': (io.BytesIO(fdata), 'baz.txt')}):
             args = parser.parse_args()
 
             self.assertEqual(args['foo'].name, 'fooaaaa')