[Python-modules-commits] [flask-restful] 01/03: Commit new upstream files
Jonathan Carter
highvoltage-guest at moszumanska.debian.org
Mon Jun 5 19:39:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
highvoltage-guest pushed a commit to branch master
in repository flask-restful.
commit 02c993cd16d31f2cdf25f1115cfb33a0e7f49377
Author: Jonathan Carter <jcarter at linux.com>
Date: Mon Jun 5 21:39:07 2017 +0200
Commit new upstream files
---
AUTHORS.md | 19 +--------
CHANGES.md | 11 ------
CONTRIBUTING.md | 2 +
README.md | 2 +-
docs/conf.py | 7 ++--
docs/extending.rst | 27 +------------
docs/fields.rst | 6 +--
docs/intermediate-usage.rst | 2 +-
docs/reqparse.rst | 5 ++-
flask_restful/__init__.py | 10 +----
flask_restful/__version__.py | 3 --
flask_restful/inputs.py | 6 +--
flask_restful/representations/json.py | 3 +-
flask_restful/reqparse.py | 12 ++----
flask_restful/utils/__init__.py | 4 --
setup.py | 22 +----------
tests/test_api.py | 74 +----------------------------------
tests/test_inputs.py | 24 ------------
tests/test_reqparse.py | 34 ----------------
tox.ini | 2 +-
20 files changed, 30 insertions(+), 245 deletions(-)
diff --git a/AUTHORS.md b/AUTHORS.md
index bbcfb5c..a6d301a 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -3,8 +3,7 @@ Authors
A huge thanks to all of our contributors:
-- Adam Chainz
-- Alec Nikolas Reiter
+
- Alex Gaynor
- Alex M
- Alex Morken
@@ -13,11 +12,9 @@ A huge thanks to all of our contributors:
- Anil Kulkarni
- Antonio Dourado
- Antonio Herraiz
-- Ares Ou
- Artur Rodrigues
- Axel Haustant
- Belousow Makc
-- Benjamin Dopplinger
- Bennett, Bryan
- Bohan Zhang
- Bryan Bennett
@@ -34,16 +31,14 @@ A huge thanks to all of our contributors:
- Dimitris Theodorou
- Doug Black
- Evan Dale Aromin
-- Eyal Levin
-- Francesco Della Vedova
- Frank Stratton
+- Frank Stratton ☺
- Garret Raziel
- Gary Belvin
- Gilles Dartiguelongue
- Giorgio Salluzzo
- Guillaume BINET
- Heston Liebowitz
-- Hu WQ
- Jacob Magnusson
- James Booth
- James Ogura
@@ -69,14 +64,12 @@ A huge thanks to all of our contributors:
- Malthe Borch
- Marek Hlobil
- Matt Wright
-- Max Mautner
- Max Peterson
- Maxim
- Michael Hwang
- Michael Newman
- Miguel Grinberg
- Mihai Tomescu
-- Neil Halelamien
- Nicolas Harraudeau
- Pavel Tyslyatsky
- Petrus J.v.Rensburg
@@ -86,16 +79,12 @@ A huge thanks to all of our contributors:
- Robert Warner
- Rod Cloutier
- Ryan Horn
-- Rémi Alvergnat
- Sam Kimbrel
- Samarth Shah
-- Sami Jaktholm
- Sander Sink
- Sasha Baranov
- Saul Diez-Guerra
- Sergey Romanov
-- Shreyans Sheth
-- Steven Leggett
- Sven-Hendrik Haase
- Usman Ehtesham Gul
- Victor Neo
@@ -103,17 +92,13 @@ A huge thanks to all of our contributors:
- Vladimir Pal
- WooParadog
- Yaniv Aknin
-- akash
- bret barker
- hachichaud
- jbouzekri
-- jobou
-- johnrichter
- justanr
- k-funk
- kelvinhammond
- kenjones
-- kieran gorman
- kumy
- lyschoening
- mailto1587
diff --git a/CHANGES.md b/CHANGES.md
index 171971a..f79e8b2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -3,17 +3,6 @@ Flask-RESTful Changelog
Here you can see the full list of changes between each Flask-RESTful release.
-Version 0.3.6
--------------
-
-Released May 31, 2017
-
-- `Argument.help` now supports unicode strings ([#564](https://github.com/flask-restful/flask-restful/pull/564))
-- Flags can now be passed to `inputs.regex` ([#621](https://github.com/flask-restful/flask-restful/pull/621))
-- Fix behavior of `action='append'` in conjunction with `location='json'` ([#645](https://github.com/flask-restful/flask-restful/pull/645))
-- `method_decorators` can be a `dict` to apply decorator behavior for only specific HTTP methods ([#532](https://github.com/flask-restful/flask-restful/pull/532))
-- JSON keys are no longer sorted by default in debug mode in python3 ([#680](https://github.com/flask-restful/flask-restful/pull/680))
-- Various small fixes and updates to documentation
Version 0.3.5
-------------
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b6a9031..078d2ee 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -6,6 +6,8 @@ issue [pull requests](https://github.com/flask-restful/flask-restful/compare).
New code must come with a set of unit tests (that pass!) before the pull request
is merged.
+Please refrain from using force pushes to update pull requests.
+
Reporting Bugs
--------------
diff --git a/README.md b/README.md
index 5e27778..4452bf4 100644
--- a/README.md
+++ b/README.md
@@ -9,5 +9,5 @@ Flask-RESTful provides the building blocks for creating a great REST API.
## User Guide
-You'll find the user guide and all documentation [here](https://flask-restful.readthedocs.io/)
+You'll find the user guide and all documentation [here](http://flask-restful.readthedocs.org/en/latest/)
diff --git a/docs/conf.py b/docs/conf.py
index 56f28cd..86fafe6 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -51,12 +51,11 @@ copyright = u'{}, Kevin Burke, Kyle Conroy, Ryan Horn, Frank Stratton, Guillaume
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
-from flask_restful.__version__ import __version__
-vparts = __version__.split('.')
+#
# The short X.Y version.
-version = '.'.join(vparts[:2])
+version = '0.2'
# The full version, including alpha/beta/rc tags.
-release = '.'.join(vparts)
+release = '0.2.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/docs/extending.rst b/docs/extending.rst
index 13710c4..8888bc6 100644
--- a/docs/extending.rst
+++ b/docs/extending.rst
@@ -21,7 +21,7 @@ mediatypes to your API, you’ll need to declare your supported representations
on the :class:`~Api` object. ::
app = Flask(__name__)
- api = Api(app)
+ api = restful.Api(app)
@api.representation('application/json')
def output_json(data, code, headers=None):
@@ -130,7 +130,7 @@ To support other representations (xml, csv, html), you can use the
:meth:`~Api.representation` decorator. You need to have a reference to your
API. ::
- api = Api(app)
+ api = restful.Api(app)
@api.representation('text/csv')
def output_csv(data, code, headers=None):
@@ -189,29 +189,6 @@ instance, if you want to build custom authentication into every request. ::
class Resource(restful.Resource):
method_decorators = [authenticate] # applies to all inherited resources
-Alternatively, you can specify a dictionary of iterables that map to HTTP methods
-and the decorators will only apply to matching requests.
-
-.. code-block:: python
-
- def cache(f):
- @wraps(f)
- def cacher(*args, **kwargs):
- # caching stuff
- return cacher
-
- class MyResource(restful.Resource):
- method_decorators = {'get': [cache]}
-
- def get(self, *args, **kwargs):
- return something_interesting(*args, **kwargs)
-
- def post(self, *args, **kwargs):
- return create_something(*args, **kwargs)
-
-In this case, the caching decorator would only apply to the `GET` request and not
-the `POST` request.
-
Since Flask-RESTful Resources are actually Flask view objects, you can also
use standard `flask view decorators <http://flask.pocoo.org/docs/views/#decorating-views>`_.
diff --git a/docs/fields.rst b/docs/fields.rst
index 58338a5..7fd8e96 100644
--- a/docs/fields.rst
+++ b/docs/fields.rst
@@ -79,7 +79,7 @@ A lambda (or any callable) can also be specified as the ``attribute`` ::
'address': fields.String,
}
-Nested properties can also be accessed with ``attribute`` ::
+Nested properties can also be accessed with ``attribute``:
fields = {
'name': fields.String(attribute='people_list.0.person_dictionary.name'),
@@ -103,7 +103,7 @@ Custom Fields & Multiple Values
-------------------------------
Sometimes you have your own custom formatting needs. You can subclass the
-:class:`fields.Raw` class and implement the format function. This is especially
+:class`fields.Raw` class and implement the format function. This is especially
useful when an attribute stores multiple pieces of information. e.g. a
bit-field whose individual bits represent distinct values. You can use fields
to multiplex a single attribute to multiple output values.
@@ -228,7 +228,7 @@ structures and render them appropriately. ::
'{"billing_address": {"line 1": "123 fake street", "line 2": null, "state": "NY", "zip": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 nowhere", "line 2": null, "state": "NY", "zip": "10468", "city": "New York"}}'
This example uses two ``Nested`` fields. The ``Nested`` constructor takes a
-dict of fields to render as sub-fields. The important difference between
+dict of fields to render as sub-fields.input The important difference between
the ``Nested`` constructor and nested dicts (previous example), is the context
for attributes. In this example, ``billing_address`` is a complex object that
has its own fields and the context passed to the nested field is the sub-object
diff --git a/docs/intermediate-usage.rst b/docs/intermediate-usage.rst
index 9ce30eb..f4399a8 100644
--- a/docs/intermediate-usage.rst
+++ b/docs/intermediate-usage.rst
@@ -261,7 +261,7 @@ So you could have a :class:`Resource`: ::
from flask_restful import Resource
class TodoNext(Resource):
- def __init__(self, **kwargs):
+ def __init__(**kwargs):
# smart_engine is a black box dependency
self.smart_engine = kwargs['smart_engine']
diff --git a/docs/reqparse.rst b/docs/reqparse.rst
index 086a5a0..33d6323 100644
--- a/docs/reqparse.rst
+++ b/docs/reqparse.rst
@@ -8,7 +8,7 @@ Request Parsing
The whole request parser part of Flask-RESTful is slated for removal and
will be replaced by documentation on how to integrate with other packages
that do the input/output stuff better
- (such as `marshmallow <https://marshmallow.readthedocs.io>`_).
+ (such as `marshmallow <http://marshmallow.readthedocs.org>`_).
This means that it will be maintained until 2.0 but consider it deprecated.
Don't worry, if you have code using that now and wish to continue doing so,
it's not going to go away any time too soon.
@@ -226,10 +226,11 @@ then the error message will be the value of ``help``.
``help`` may include an interpolation token, ``{error_msg}``, that will be
replaced with the string representation of the type error. This allows the
-message to be customized while preserving the original error ::
+message to be customized while preserving the original error:
from flask_restful import reqparse
+
parser = reqparse.RequestParser()
parser.add_argument(
'foo',
diff --git a/flask_restful/__init__.py b/flask_restful/__init__.py
index e18d6f1..82a708a 100644
--- a/flask_restful/__init__.py
+++ b/flask_restful/__init__.py
@@ -17,7 +17,6 @@ import sys
from flask.helpers import _endpoint_from_view_func
from types import MethodType
import operator
-from collections import Mapping
__all__ = ('Api', 'Resource', 'marshal', 'marshal_with', 'marshal_with_field', 'abort')
@@ -51,7 +50,6 @@ class Api(object):
:param app: the Flask application object
:type app: flask.Flask
- :type app: flask.Blueprint
:param prefix: Prefix all routes with a value, eg v1 or 2010-04-01
:type prefix: str
:param default_mediatype: The default media type to return
@@ -372,7 +370,6 @@ class Api(object):
:param resource: the class name of your resource
:type resource: :class:`Resource`
-
:param urls: one or more url routes to match for the resource, standard
flask routing rules apply. Any url variables will be
passed to the resource method as args.
@@ -584,12 +581,7 @@ class Resource(MethodView):
meth = getattr(self, 'get', None)
assert meth is not None, 'Unimplemented method %r' % request.method
- if isinstance(self.method_decorators, Mapping):
- decorators = self.method_decorators.get(request.method.lower(), [])
- else:
- decorators = self.method_decorators
-
- for decorator in decorators:
+ for decorator in self.method_decorators:
meth = decorator(meth)
resp = meth(*args, **kwargs)
diff --git a/flask_restful/__version__.py b/flask_restful/__version__.py
deleted file mode 100644
index ee19d4e..0000000
--- a/flask_restful/__version__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env python
-
-__version__ = '0.3.6'
diff --git a/flask_restful/inputs.py b/flask_restful/inputs.py
index 141fa9a..2d2ad25 100644
--- a/flask_restful/inputs.py
+++ b/flask_restful/inputs.py
@@ -53,13 +53,11 @@ class regex(object):
:param pattern: The regular expression the input must match
:type pattern: str
- :param flags: Flags to change expression behavior
- :type flags: int
"""
- def __init__(self, pattern, flags=0):
+ def __init__(self, pattern):
self.pattern = pattern
- self.re = re.compile(pattern, flags)
+ self.re = re.compile(pattern)
def __call__(self, value):
if not self.re.search(value):
diff --git a/flask_restful/representations/json.py b/flask_restful/representations/json.py
index ccbe8b7..f96189e 100644
--- a/flask_restful/representations/json.py
+++ b/flask_restful/representations/json.py
@@ -1,6 +1,5 @@
from __future__ import absolute_import
from flask import make_response, current_app
-from flask_restful.utils import PY3
from json import dumps
@@ -14,7 +13,7 @@ def output_json(data, code, headers=None):
# that was set. We also set the "sort_keys" value.
if current_app.debug:
settings.setdefault('indent', 4)
- settings.setdefault('sort_keys', not PY3)
+ settings.setdefault('sort_keys', True)
# always end the json dumps with a new line
# see https://github.com/mitsuhiko/flask/pull/1262
diff --git a/flask_restful/reqparse.py b/flask_restful/reqparse.py
index 8fe142e..07e42d9 100644
--- a/flask_restful/reqparse.py
+++ b/flask_restful/reqparse.py
@@ -1,6 +1,4 @@
from copy import deepcopy
-
-import collections
from flask import current_app, request
from werkzeug.datastructures import MultiDict, FileStorage
from werkzeug import exceptions
@@ -145,7 +143,7 @@ class Argument(object):
"""
error_str = six.text_type(error)
error_msg = self.help.format(error_msg=error_str) if self.help else error_str
- msg = {self.name: error_msg}
+ msg = {self.name: "{0}".format(error_msg)}
if current_app.config.get("BUNDLE_ERRORS", False) or bundle_errors:
return error, msg
@@ -175,9 +173,7 @@ class Argument(object):
if hasattr(source, "getlist"):
values = source.getlist(name)
else:
- values = source.get(name)
- if not isinstance(values, collections.MutableSequence):
- values = [values]
+ values = [source.get(name)]
for value in values:
if hasattr(value, "strip") and self.trim:
@@ -242,9 +238,9 @@ class RequestParser(object):
"""Enables adding and parsing of multiple arguments in the context of a
single request. Ex::
- from flask_restful import reqparse
+ from flask import request
- parser = reqparse.RequestParser()
+ parser = RequestParser()
parser.add_argument('foo')
parser.add_argument('int_bar', type=int)
args = parser.parse_args()
diff --git a/flask_restful/utils/__init__.py b/flask_restful/utils/__init__.py
index 7d6baec..ffbae22 100644
--- a/flask_restful/utils/__init__.py
+++ b/flask_restful/utils/__init__.py
@@ -1,5 +1,3 @@
-import sys
-
try:
from collections import OrderedDict
except ImportError:
@@ -7,8 +5,6 @@ except ImportError:
from werkzeug.http import HTTP_STATUS_CODES
-PY3 = sys.version_info > (3,)
-
def http_status_message(code):
"""Maps an HTTP status code to the textual status"""
diff --git a/setup.py b/setup.py
index b45dee6..f9fc494 100755
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python
-import re
-import sys
-from os import path
from setuptools import setup, find_packages
+import sys
PY26 = sys.version_info[:2] == (2, 6,)
@@ -16,24 +14,9 @@ requirements = [
if PY26:
requirements.append('ordereddict')
-
-version_file = path.join(
- path.dirname(__file__),
- 'flask_restful',
- '__version__.py'
-)
-with open(version_file, 'r') as fp:
- m = re.search(
- r"^__version__ = ['\"]([^'\"]*)['\"]",
- fp.read(),
- re.M
- )
- version = m.groups(1)[0]
-
-
setup(
name='Flask-RESTful',
- version=version,
+ version='0.3.5',
license='BSD',
url='https://www.github.com/flask-restful/flask-restful/',
author='Twilio API Team',
@@ -49,7 +32,6 @@ setup(
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6',
'License :: OSI Approved :: BSD License',
],
zip_safe=False,
diff --git a/tests/test_api.py b/tests/test_api.py
index 26447ae..bb8d362 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -9,7 +9,7 @@ except:
from unittest.mock import Mock
import flask
import werkzeug
-from werkzeug.exceptions import HTTPException, Unauthorized, BadRequest, NotFound, _aborter
+from werkzeug.exceptions import HTTPException, Unauthorized, BadRequest, NotFound
from werkzeug.http import quote_etag, unquote_etag
from flask_restful.utils import http_status_message, unpack
import flask_restful
@@ -808,7 +808,7 @@ class APITestCase(unittest.TestCase):
flask_abort(304, etag='myETag')
api.add_resource(Foo1, '/foo')
- _aborter.mapping.update({304: NotModified})
+ flask_abort.mapping.update({304: NotModified})
with app.test_client() as client:
foo = client.get('/foo')
@@ -982,76 +982,6 @@ class APITestCase(unittest.TestCase):
except AttributeError as ae:
self.fail(ae.message)
- def test_selectively_apply_method_decorators(self):
- def upper_deco(f):
- def upper(*args, **kwargs):
- return f(*args, **kwargs).upper()
- return upper
-
- class TestResource(flask_restful.Resource):
- method_decorators = {'get': [upper_deco]}
-
- def get(self):
- return 'get test'
-
- def post(self):
- return 'post test'
-
- app = Flask(__name__)
-
- with app.test_request_context('/', method='POST'):
- r = TestResource().dispatch_request()
- assert r == 'post test'
-
- with app.test_request_context('/', method='GET'):
- r = TestResource().dispatch_request()
- assert r == 'GET TEST'
-
- def test_apply_all_method_decorators_if_not_mapping(self):
- def upper_deco(f):
- def upper(*args, **kwargs):
- return f(*args, **kwargs).upper()
- return upper
-
- class TestResource(flask_restful.Resource):
- method_decorators = [upper_deco]
-
- def get(self):
- return 'get test'
-
- def post(self):
- return 'post test'
-
- app = Flask(__name__)
-
- with app.test_request_context('/', method='POST'):
- r = TestResource().dispatch_request()
- assert r == 'POST TEST'
-
- with app.test_request_context('/', method='GET'):
- r = TestResource().dispatch_request()
- assert r == 'GET TEST'
-
- def test_decorators_only_applied_at_dispatch(self):
- def upper_deco(f):
- def upper(*args, **kwargs):
- return f(*args, **kwargs).upper()
- return upper
-
- class TestResource(flask_restful.Resource):
- method_decorators = [upper_deco]
-
- def get(self):
- return 'get test'
-
- def post(self):
- return 'post test'
-
- r = TestResource()
-
- assert r.get() == 'get test'
- assert r.post() == 'post test'
-
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_inputs.py b/tests/test_inputs.py
index 90a2fb0..dfd34e8 100644
--- a/tests/test_inputs.py
+++ b/tests/test_inputs.py
@@ -140,30 +140,6 @@ def test_regex_bad_pattern():
assert_raises(re.error, inputs.regex, '[')
-def test_regex_flags_good_input():
- cases = (
- 'abcd',
- 'ABCabc',
- 'ABC',
- )
-
- case_insensitive = inputs.regex(r'^[A-Z]+$', re.IGNORECASE)
-
- for value in cases:
- yield assert_equal, case_insensitive(value), value
-
-
-def test_regex_flags_bad_input():
- cases = (
- 'abcd',
- 'ABCabc'
- )
-
- case_sensitive = inputs.regex(r'^[A-Z]+$')
-
- for value in cases:
- yield assert_raises, ValueError, lambda: case_sensitive(value)
-
class TypesTestCase(unittest.TestCase):
diff --git a/tests/test_reqparse.py b/tests/test_reqparse.py
index ce9ce30..b0cb136 100644
--- a/tests/test_reqparse.py
+++ b/tests/test_reqparse.py
@@ -30,19 +30,6 @@ class ReqParseTestCase(unittest.TestCase):
abort.assert_called_with(400, message=expected)
@patch('flask_restful.abort')
- def test_help_with_unicode_error_msg(self, abort):
- app = Flask(__name__)
- with app.app_context():
- parser = RequestParser()
- parser.add_argument('foo', choices=('one', 'two'), help=u'Bad choice: {error_msg}')
- req = Mock(['values'])
- req.values = MultiDict([('foo', u'\xf0\x9f\x8d\x95')])
- parser.parse_args(req)
- expected = {'foo': u'Bad choice: \xf0\x9f\x8d\x95 is not a valid choice'}
- abort.assert_called_with(400, message=expected)
-
-
- @patch('flask_restful.abort')
def test_help_no_error_msg(self, abort):
app = Flask(__name__)
with app.app_context():
@@ -302,27 +289,6 @@ class ReqParseTestCase(unittest.TestCase):
args = parser.parse_args(req)
self.assertEquals(args['foo'], ["bar"])
- def test_parse_append_many(self):
- req = Request.from_values("/bubble?foo=bar&foo=bar2")
-
- parser = RequestParser()
- parser.add_argument("foo", action="append"),
-
- args = parser.parse_args(req)
- self.assertEquals(args['foo'], ["bar", "bar2"])
-
- def test_parse_append_many_location_json(self):
- app = Flask(__name__)
-
- parser = RequestParser()
- parser.add_argument("foo", action='append', location="json")
-
- with app.test_request_context('/bubble', method="post",
- data=json.dumps({"foo": ["bar", "bar2"]}),
- content_type='application/json'):
- args = parser.parse_args()
- self.assertEquals(args['foo'], ['bar', 'bar2'])
-
def test_parse_dest(self):
req = Request.from_values("/bubble?foo=bar")
diff --git a/tox.ini b/tox.ini
index 0a77e34..a40c5b4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,7 +4,7 @@
# and then run "tox" from this directory.
[tox]
-envlist = py26, py27, py33, py34, py35, py36
+envlist = py26, py27, py33, py34
[testenv]
usedevelop = true
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/flask-restful.git
More information about the Python-modules-commits
mailing list