From 47d7f20d9b291778992920e0a4e3d9ac85b139c4 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:03:07 +0100 Subject: [PATCH 01/12] Fix two typos in the description of FlaskGroup. --- flask/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flask/cli.py b/flask/cli.py index 8b75643a..47c0406a 100644 --- a/flask/cli.py +++ b/flask/cli.py @@ -257,10 +257,10 @@ class AppGroup(click.Group): class FlaskGroup(AppGroup): - """Special subclass of the the :class:`AppGroup` group that supports + """Special subclass of the :class:`AppGroup` group that supports loading more commands from the configured Flask app. Normally a developer does not have to interface with this class but there are - some very advanced usecases for which it makes sense to create an + some very advanced use cases for which it makes sense to create an instance of this. For information as of why this is useful see :ref:`custom-scripts`. From e41bf1e18104bfc2e482aa9f066c3ee7793666b4 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:13:03 +0100 Subject: [PATCH 02/12] Remove two redundant empty lines. PEP8 suggests to use two empty lines to separate functions, not three. --- tests/conftest.py | 1 - tests/test_signals.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index adbf3629..7b24be3d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -33,7 +33,6 @@ def leak_detector(request): request.addfinalizer(ensure_clean_request_context) - @pytest.fixture(params=(True, False)) def limit_loader(request, monkeypatch): """Patch pkgutil.get_loader to give loader without get_filename or archive. diff --git a/tests/test_signals.py b/tests/test_signals.py index b726d7b4..e9cabb93 100644 --- a/tests/test_signals.py +++ b/tests/test_signals.py @@ -19,7 +19,6 @@ except ImportError: import flask - pytestmark = pytest.mark.skipif( blinker is None, reason='Signals require the blinker library.' From 4840fc0edc6609d51342d4c5e21b7843109e3c16 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:17:49 +0100 Subject: [PATCH 03/12] Change `== None` to `is None`. PEP8 (E711) suggests that comparison to None should be `cond is None`. --- tests/test_appctx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_appctx.py b/tests/test_appctx.py index eea4e915..a3db4547 100644 --- a/tests/test_appctx.py +++ b/tests/test_appctx.py @@ -41,13 +41,13 @@ def test_request_context_means_app_context(): app = flask.Flask(__name__) with app.test_request_context(): assert flask.current_app._get_current_object() == app - assert flask._app_ctx_stack.top == None + assert flask._app_ctx_stack.top is None def test_app_context_provides_current_app(): app = flask.Flask(__name__) with app.app_context(): assert flask.current_app._get_current_object() == app - assert flask._app_ctx_stack.top == None + assert flask._app_ctx_stack.top is None def test_app_tearing_down(): cleanup_stuff = [] From ec3d5800f2c8d6803c426babb0b6df0fa36f866f Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:24:15 +0100 Subject: [PATCH 04/12] Put two spaces before inline comments when there is only one space. PEP8 (E261) suggests to use at least two spaces before inline comments. --- flask/app.py | 2 +- flask/helpers.py | 2 +- tests/test_templating.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flask/app.py b/flask/app.py index 4e97605e..58ccbae4 100644 --- a/flask/app.py +++ b/flask/app.py @@ -289,7 +289,7 @@ class Flask(_PackageBoundObject): 'SESSION_COOKIE_SECURE': False, 'SESSION_REFRESH_EACH_REQUEST': True, 'MAX_CONTENT_LENGTH': None, - 'SEND_FILE_MAX_AGE_DEFAULT': 12 * 60 * 60, # 12 hours + 'SEND_FILE_MAX_AGE_DEFAULT': 12 * 60 * 60, # 12 hours 'TRAP_BAD_REQUEST_ERRORS': False, 'TRAP_HTTP_EXCEPTIONS': False, 'EXPLAIN_TEMPLATE_LOADING': False, diff --git a/flask/helpers.py b/flask/helpers.py index 9c85fa00..cd29095b 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -573,7 +573,7 @@ def safe_join(directory, filename): def wiki_page(filename): filename = safe_join(app.config['WIKI_FOLDER'], filename) with open(filename, 'rb') as fd: - content = fd.read() # Read and process the file content... + content = fd.read() # Read and process the file content... :param directory: the base directory. :param filename: the untrusted filename relative to that directory. diff --git a/tests/test_templating.py b/tests/test_templating.py index 5aaf9081..cda49d9b 100644 --- a/tests/test_templating.py +++ b/tests/test_templating.py @@ -287,8 +287,8 @@ def test_iterable_loader(): @app.route('/') def index(): return flask.render_template( - ['no_template.xml', # should skip this one - 'simple_template.html', # should render this + ['no_template.xml', # should skip this one + 'simple_template.html', # should render this 'context_template.html'], value=23) From ebab6718f7dbafaa2e893f2347e6fdc6acad8504 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:31:01 +0100 Subject: [PATCH 05/12] Unify the uses of "testsuite" vs "test suite". Use "test suite", which is more prevailing in the source code. --- CHANGES | 2 +- docs/patterns/fabric.rst | 2 +- docs/upgrading.rst | 2 +- flask/ctx.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 5df663ea..a1b2bdd8 100644 --- a/CHANGES +++ b/CHANGES @@ -49,7 +49,7 @@ Version 1.0 users debug when the wrong templates are loaded. - Enforce blueprint handling in the order they were registered for template loading. -- Ported testsuite to py.test. +- Ported test suite to py.test. - Deprecated ``request.json`` in favour of ``request.get_json()``. - Add "pretty" and "compressed" separators definitions in jsonify() method. Reduces JSON response size when JSONIFY_PRETTYPRINT_REGULAR=False by removing diff --git a/docs/patterns/fabric.rst b/docs/patterns/fabric.rst index e915103b..873bf47a 100644 --- a/docs/patterns/fabric.rst +++ b/docs/patterns/fabric.rst @@ -186,7 +186,7 @@ deployment actually fun: out the latest version on the server and then install. That way you can also easily go back to older versions. - hook in testing functionality so that you can deploy to an external - server and run the testsuite. + server and run the test suite. Working with Fabric is fun and you will notice that it's quite magical to type ``fab deploy`` and see your application being deployed automatically diff --git a/docs/upgrading.rst b/docs/upgrading.rst index fa32efb5..019019d0 100644 --- a/docs/upgrading.rst +++ b/docs/upgrading.rst @@ -96,7 +96,7 @@ as `ValueError` you will need to change this. Due to a bug in the test client Flask 0.7 did not trigger teardown handlers when the test client was used in a with statement. This was -since fixed but might require some changes in your testsuites if you +since fixed but might require some changes in your test suites if you relied on this behavior. Version 0.7 diff --git a/flask/ctx.py b/flask/ctx.py index 5e3ee4ed..d79ad00d 100644 --- a/flask/ctx.py +++ b/flask/ctx.py @@ -291,7 +291,7 @@ class RequestContext(object): # information under debug situations. However if someone forgets to # pop that context again we want to make sure that on the next push # it's invalidated, otherwise we run at risk that something leaks - # memory. This is usually only a problem in testsuite since this + # memory. This is usually only a problem in test suite since this # functionality is not active in production environments. top = _request_ctx_stack.top if top is not None and top.preserved: From d1423b3e16c17519d2d8841ea2547244cc6aa944 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:33:45 +0100 Subject: [PATCH 06/12] Unify the uses of "file system" vs "fileystem". Use "filesystem", which is more prevailing in the source code. --- docs/quickstart.rst | 2 +- flask/app.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 572f8133..14753b59 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -222,7 +222,7 @@ The following converters exist: Though they look rather similar, they differ in their use of the trailing slash in the URL *definition*. In the first case, the canonical URL for the `projects` endpoint has a trailing slash. In that sense, it is similar to - a folder on a file system. Accessing it without a trailing slash will cause + a folder on a filesystem. Accessing it without a trailing slash will cause Flask to redirect to the canonical URL with the trailing slash. In the second case, however, the URL is defined without a trailing slash, diff --git a/flask/app.py b/flask/app.py index 58ccbae4..c1111b3f 100644 --- a/flask/app.py +++ b/flask/app.py @@ -85,7 +85,7 @@ class Flask(_PackageBoundObject): The idea of the first parameter is to give Flask an idea of what belongs to your application. This name is used to find resources - on the file system, can be used by extensions to improve debugging + on the filesystem, can be used by extensions to improve debugging information and a lot more. So it's important what you provide there. If you are using a single From 3767e7ba4f333e5347a6e7b06e6261b8a579c3e5 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:36:23 +0100 Subject: [PATCH 07/12] Unify the uses of "urls" vs "URLs". Use "URLs", which is more prevailing in the source code. --- .../blueprintexample/simple_page/templates/pages/layout.html | 2 +- flask/helpers.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/blueprintexample/simple_page/templates/pages/layout.html b/examples/blueprintexample/simple_page/templates/pages/layout.html index 5eaa8fc6..f312d44b 100644 --- a/examples/blueprintexample/simple_page/templates/pages/layout.html +++ b/examples/blueprintexample/simple_page/templates/pages/layout.html @@ -4,7 +4,7 @@

This is blueprint example

A simple page blueprint is registered under / and /pages - you can access it using this urls: + you can access it using this URLs:

  • /hello
  • /world diff --git a/flask/helpers.py b/flask/helpers.py index cd29095b..ead20d70 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -264,7 +264,7 @@ def url_for(endpoint, **values): 'executed when application context is available.') # If request specific information is available we have some extra - # features that support "relative" urls. + # features that support "relative" URLs. if reqctx is not None: url_adapter = reqctx.url_adapter blueprint_name = request.blueprint @@ -284,7 +284,7 @@ def url_for(endpoint, **values): external = values.pop('_external', False) # Otherwise go with the url adapter from the appctx and make - # the urls external by default. + # the URLs external by default. else: url_adapter = appctx.url_adapter if url_adapter is None: From 0f3f476dcfd2974aa73a3c741e0f6d94d662885e Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:40:50 +0100 Subject: [PATCH 08/12] Fix a typo in the description of SecureCookieSession. The term "base class" (with a space) is used in another file, so use it here as well to make the wording consistent across the whole project. --- flask/sessions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask/sessions.py b/flask/sessions.py index c2ba3213..2bf455f4 100644 --- a/flask/sessions.py +++ b/flask/sessions.py @@ -110,7 +110,7 @@ session_json_serializer = TaggedJSONSerializer() class SecureCookieSession(CallbackDict, SessionMixin): - """Baseclass for sessions based on signed cookies.""" + """Base class for sessions based on signed cookies.""" def __init__(self, initial=None): def on_update(self): From 92854cb3861f33bff7949be94b5d70ed9262b26d Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:42:40 +0100 Subject: [PATCH 09/12] Add a missing period in the description of the signals module. --- flask/signals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask/signals.py b/flask/signals.py index e9f7239d..5951128b 100644 --- a/flask/signals.py +++ b/flask/signals.py @@ -4,7 +4,7 @@ ~~~~~~~~~~~~~ Implements signals based on blinker if available, otherwise - falls silently back to a noop + falls silently back to a noop. :copyright: (c) 2014 by Armin Ronacher. :license: BSD, see LICENSE for more details. From 3159c861664eed1a3f82b4b4313ba15b7436a18c Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:45:00 +0100 Subject: [PATCH 10/12] Unify the uses of "sourcecode" vs "source code". Use "source code", which is more grammatically correct. --- docs/license.rst | 2 +- docs/patterns/fabric.rst | 2 +- docs/tutorial/index.rst | 2 +- flask/signals.py | 2 +- flask/templating.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/license.rst b/docs/license.rst index 38777e66..696ee676 100644 --- a/docs/license.rst +++ b/docs/license.rst @@ -26,7 +26,7 @@ documentation. - "AUTHORS" hereby refers to all the authors listed in the :ref:`authors` section. -- The ":ref:`flask-license`" applies to all the sourcecode shipped as +- The ":ref:`flask-license`" applies to all the source code shipped as part of Flask (Flask itself as well as the examples and the unittests) as well as documentation. diff --git a/docs/patterns/fabric.rst b/docs/patterns/fabric.rst index 873bf47a..bdbfa634 100644 --- a/docs/patterns/fabric.rst +++ b/docs/patterns/fabric.rst @@ -32,7 +32,7 @@ hosts. These hosts can be defined either in the fabfile or on the command line. In this case we will add them to the fabfile. This is a basic first example that has the ability to upload the current -sourcecode to the server and install it into a pre-existing +source code to the server and install it into a pre-existing virtual environment:: from fabric.api import * diff --git a/docs/tutorial/index.rst b/docs/tutorial/index.rst index beb22709..326cea9f 100644 --- a/docs/tutorial/index.rst +++ b/docs/tutorial/index.rst @@ -11,7 +11,7 @@ features everything you need to get started. We will use Flask and SQLite as database which comes out of the box with Python, so there is nothing else you need. -If you want the full sourcecode in advance or for comparison, check out +If you want the full source code in advance or for comparison, check out the `example source`_. .. _example source: diff --git a/flask/signals.py b/flask/signals.py index 5951128b..cc584a6c 100644 --- a/flask/signals.py +++ b/flask/signals.py @@ -42,7 +42,7 @@ except ImportError: _signals = Namespace() -# Core signals. For usage examples grep the sourcecode or consult +# Core signals. For usage examples grep the source code or consult # the API documentation in docs/api.rst as well as docs/signals.rst template_rendered = _signals.signal('template-rendered') request_started = _signals.signal('request-started') diff --git a/flask/templating.py b/flask/templating.py index 9334e0d6..8ec0d02d 100644 --- a/flask/templating.py +++ b/flask/templating.py @@ -127,7 +127,7 @@ def render_template_string(source, **context): """Renders a template from the given template source string with the given context. - :param source: the sourcecode of the template to be + :param source: the source code of the template to be rendered :param context: the variables that should be available in the context of the template. From 6b9fd4a968dc314ec03c6e5c08c5939667f1634c Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:46:33 +0100 Subject: [PATCH 11/12] Fix a typo in a comment in MethodViewType.__new__. --- flask/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask/views.py b/flask/views.py index a216241a..d72ad234 100644 --- a/flask/views.py +++ b/flask/views.py @@ -113,7 +113,7 @@ class MethodViewType(type): methods.add(key.upper()) # If we have no method at all in there we don't want to # add a method list. (This is for instance the case for - # the baseclass or another subclass of a base method view + # the base class or another subclass of a base method view # that does not introduce new methods). if methods: rv.methods = sorted(methods) From d4f6734741929f7532c03b00e732bf7db42f7c01 Mon Sep 17 00:00:00 2001 From: Petr Zemek Date: Mon, 27 Oct 2014 11:54:30 +0100 Subject: [PATCH 12/12] Remove a redundant "the" in a comment. --- flask/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask/helpers.py b/flask/helpers.py index ead20d70..aaed81c4 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -529,7 +529,7 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False, rv = current_app.response_class(data, mimetype=mimetype, headers=headers, direct_passthrough=True) - # if we know the file modification date, we can store it as the + # if we know the file modification date, we can store it as # the time of the last modification. if mtime is not None: rv.last_modified = int(mtime)