Commit graph

665 commits

Author SHA1 Message Date
David Lord
43483683b2
apply reorder-python-imports pre-commit config 2019-06-01 09:07:20 -07:00
Jon S. Stumpf
b46f5942a5
address flake8 issues 2019-06-01 06:31:35 -07:00
Jon S. Stumpf
549fed29ea
add pre-commit config for flake8 2019-06-01 09:13:46 -04:00
cslecrone
1718f1934c
don't require ssl module for flask cli 2019-05-31 17:27:52 -04:00
Daniel Pope
c7f56c5a55 Create json_dumps() method on new EnvironBuilder 2019-05-31 18:05:25 +01:00
Daniel Pope
976dfedaa9 Convert make_test_environ_builder into class (fixes #3207) 2019-05-31 18:05:25 +01:00
David Lord
91e53da054
Merge pull request #3236 from lordmauve/no-cligroup-empty
Do not register empty CLI groups from Blueprint
2019-05-31 13:05:00 -04:00
John Zeringue
8bb7185284 Better error message when view return type is not supported
Before, returning a `bool` from a route caused the error

```
[2019-05-31 10:08:42,216] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2070, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 269, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 26, in _run_wsgi_app
    return _run_wsgi_app(*args)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/test.py", line 1119, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'bool' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2393, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1906, in full_dispatch_request
    return self.finalize_request(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1921, in finalize_request
    response = self.make_response(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2078, in make_response
    reraise(TypeError, new_error, sys.exc_info()[2])
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/_compat.py", line 39, in reraise
    raise value.with_traceback(tb)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2070, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 269, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 26, in _run_wsgi_app
    return _run_wsgi_app(*args)
  File "/Users/johnzeringue/Documents/ts-open/flask/env/lib/python3.7/site-packages/werkzeug/test.py", line 1119, in run_wsgi_app
    app_rv = app(environ, start_response)
TypeError: 'bool' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a bool.
```

Now, it returns the more readable

```
[2019-05-31 10:36:19,500] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2400, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1907, in full_dispatch_request
    return self.finalize_request(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 1922, in finalize_request
    response = self.make_response(rv)
  File "/Users/johnzeringue/Documents/ts-open/flask/flask/app.py", line 2085, in make_response
    " {rv.__class__.__name__}.".format(rv=rv))
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a bool.
```

Fixes #3214
2019-05-31 11:58:49 -04:00
Daniel Pope
f25b5000fd Do not register empty CLI groups from Blueprint
(Fixes #3224)
2019-05-31 16:49:01 +01:00
Daniel Pope
a5ff3cd01b Fix style issues on master using Black 2019-05-31 11:57:28 +01:00
Fantix King
a71c167836
fix teardown bug in FlaskClient
* Fixes pytest-dev/pytest-flask#42
2019-05-25 14:03:28 -07:00
David Lord
ed9ab2d3b6
strip static url trailing slash at assignment 2019-05-25 11:18:40 -07:00
Pete Beardmore
a12bf290da
fix 'static_url_path' defaulting for empty paths
-prefix a path delimiter iff there's a path to delimit
-ensures a valid default static route rule is created on application
intialisation for the case 'static_folder=""' and implicit
'static_url_path'
2019-05-25 07:03:36 -07:00
Anthony Plunkett
ec1ccd7530
Add Blueprint level cli command registration
Implements #1357.
Adds ability to register click cli commands onto blueprint.
2019-05-24 14:43:29 -07:00
pgjones
7bf8366970
Allow dictionary return values as JSON
This supports an increasingly common usecase whereby JSON is the
primary response (rather than a templated string). Given Flask has a
short syntax for HTML reponses, it seems fitting that it should also
do so for JSON responses. In practice it allows,

     @app.route("/")
     def index():
         return {
             "api_stuff": "values",
         }
2019-05-24 09:48:55 -07:00
Adarsh Sharma
db8cb31f2b
Fix #2937: Ensure the consistency in load_dotenv's return type 2019-05-19 11:58:39 -07:00
vorelq
e1cc16f8be
Fix 0 port value being overriden by default
By explicitly comparing port value with None,
instead of using its bool() value.
2019-05-19 11:36:47 -07:00
Eruvanos
6af14f058b
support dataclass in JSONEncoder 2019-05-18 21:37:54 -07:00
Frankie Liu
2039e2e3b6
Remove ending slash from static_url_path 2019-05-18 21:23:14 -07:00
EtiennePelletier
8590d65a57
Use Werkzeug's JSONMixin class and update tests
Flask's JSONMixin class was moved to Werkzeug>=0.15

Co-authored-by: Jeffrey Eliasen <jeff@jke.net>
2019-05-18 20:57:26 -07:00
LeeW
1f3923a999
Inherit "methods" in MethodView
* Current behavior: If a base class inherits MethodView and child class
  inherits without overwriting "methods". The "methods" defined in base
  class would be ignored
* Fix: Inherit all the "methods" defined in base classes if "methods"
  variable is not overwritten
2019-05-17 13:57:06 -07:00
David Lord
6f703a564c
clean up open_resource and tests 2019-05-17 13:23:27 -07:00
icreatedanaccount
ad709be46e
Allow mode='rt' on open_resource() helper 2019-05-17 13:22:13 -07:00
David Lord
05a4e15ee4
Merge branch '1.0.x' 2019-05-17 11:13:08 -07:00
David Lord
a4f0f19796
don't push app context for test client json 2019-05-17 09:00:08 -07:00
David Baumgold
025589ee76 Reformat with black
https://github.com/python/black
2019-05-06 16:28:58 -04:00
David Lord
a74864ec22
Merge remote-tracking branch 'origin/1.0-maintenance' 2019-01-07 10:00:10 -08:00
David Lord
662ce2151d
add changelog for GH-2986 2019-01-07 09:52:54 -08:00
Jimmy Jia
b92b2e6c74
Do not handle RoutingExceptions with app error handlers 2019-01-07 09:01:37 -08:00
garenchan
40118e785f
Make sure the attachment filename is text type.
If attachment filename is bytes type and contains non-ascii coded bytes,
then the following ASCII encoding process will trigger
UnicodeDecodeError exception.

Fix issue #2933.
2019-01-07 07:17:33 -08:00
David Lord
366f3f49af
add changelog for GH-2957 2019-01-07 06:56:20 -08:00
Ignasi Bosch
b570bf699c
Allow partial content on bytesio 2019-01-07 06:17:36 -08:00
David Lord
4f3dbb3f3b
Merge branch '1.0-maintenance' 2019-01-06 16:33:17 -08:00
David Lord
a0ccc47780
clean up flask --version code 2019-01-06 16:24:05 -08:00
Matt Robenolt
25de45cbb6
Add support for PathLike objects in static file helpers
See: https://www.python.org/dev/peps/pep-0519/

This is mostly encountered with pathlib in python 3, but this API
suggests any PathLike object can be treated like a filepath with
`__fspath__` function.
2019-01-05 15:23:47 -08:00
David Lord
f7d50d4b67
Merge branch '1.0-maintenance' 2019-01-05 15:12:17 -08:00
David Lord
49efc44233
clear KeyError in production for Werkzeug 0.15 2019-01-05 12:49:59 -08:00
Jarek Piórkowski
9b0bd91195 Correct tests
We've discovered that passing Unicode in Host actually works, except for
test client limitations on Python 2 - and the only things that don't
work are non-printable characters.
2018-11-13 13:09:16 -05:00
Jarek Piórkowski
ed9775fb77 Handle errors during create_url_adapter
If create_url_adapter raises (which it can if werkzeug cannot bind
environment, for example on non-ASCII Host header), we handle it as
other routing exceptions rather than raising through.

ref https://github.com/pallets/werkzeug/issues/640
2018-11-12 16:59:09 -05:00
Dave Chevell
e08bcf9f97 Fix #2935: Copy current session object in copy_current_request_context (#2936)
Add session to RequestContext.copy()
2018-11-03 20:32:24 -07:00
garenchan
c38499bbf2 ignore colon with slash when split app_import_path
Flask currently supports importing app through a combination of module
path and app variable name, such as '/usr/app.py:my_app'. When the
module path contains a colon, it will conflict with this import way and
a `flask.cli.NoAppException` will be raised.

A file path on a Windows system may contain a colon followed by a slash.
So we solved this problem on Windows by ignoring the colon followed by a
slash when we split app_import_path.

Fix issue #2961.
2018-10-24 23:47:41 +08:00
ThiefMaster
161c43649d Merge branch '1.0-maintenance' 2018-06-14 13:31:40 +02:00
ThiefMaster
50227f0954 Add option to not overwrite debug flag in cli
This is mainly intended for custom CLIs that may load a config file
which already sets the debug flag and does not make use of the `FLASK_*`
env vars at all.
2018-06-14 13:25:05 +02:00
Grey Li
4025e27b57 Add test for routes command when no routes registered 2018-05-31 11:43:51 +08:00
Dilan Coss
8fa3ed13bf details fixed 2018-05-29 09:51:08 -06:00
Dilan Coss
8cdd01ea5d Test added for _AppCtxGlobals __repr__ method 2018-05-28 23:49:06 -06:00
David Lord
b51ab3ff2c
encode filenames as ascii instead of latin-1
latin-1 is allowed by pep3333, but that breaks gunicorn
2018-05-28 06:36:47 -07:00
Briehan Lombaard
a913b4dafd
SSLContext was added in Python 2.7.9 2018-05-17 06:18:42 -07:00
David Lord
b21b4d1608
add more merge cases 2018-05-01 13:29:48 -07:00
Hsiaoming Yang
f7a3bdc6db
Fix blueprint route for "" 2018-05-01 14:35:55 +09:00