Merge pull request #3246 from pallets/reorder-imports
Before adoption: this commit came in with the history the project adopted, so no landing records it.
apply reorder-python-imports pre-commit config
authored by David Lord · committed by GitHub · parents ab8d60d, 4348368 · Browse files · 56 files·+290 added−245 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
56 files+290 added−245 removed
- tests:+70 added−61 removed
- other:+220 added−184 removed
Provenance
- Commit
3db4697- Tree
ec5e6e3- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
ab8d60d- Parent 2
4348368
56 files changed+290 added−245 removed
modified:examples/javascript/js_example/views.py+3 added-1 removed
1-from flask import jsonify, render_template, request1+from flask import jsonify2+from flask import render_template3+from flask import request4 5 from js_example import app6 7 11 unmodified linesmodified:examples/javascript/tests/test_js_example.py-1 removed
1 import pytest2-2 from flask import template_rendered3 4 5 @pytest.mark.parametrize(22 unmodified linesmodified:examples/javascript/setup.py+2 added-1 removed
1 import io2 3-from setuptools import find_packages, setup3+from setuptools import find_packages4+from setuptools import setup5 6 with io.open("README.rst", "rt", encoding="utf8") as f:7 readme = f.read()8 15 unmodified linesmodified:examples/tutorial/flaskr/auth.py+10 added-11 removed
1 import functools2 3-from flask import (4- Blueprint,5- flash,6- g,7- redirect,8- render_template,9- request,10- session,11- url_for,12-)13-from werkzeug.security import check_password_hash, generate_password_hash3+from flask import Blueprint4+from flask import flash5+from flask import g6+from flask import redirect7+from flask import render_template8+from flask import request9+from flask import session10+from flask import url_for11+from werkzeug.security import check_password_hash12+from werkzeug.security import generate_password_hash13 14 from flaskr.db import get_db15 16 bp = Blueprint("auth", __name__, url_prefix="/auth")100 unmodified linesmodified:examples/tutorial/flaskr/blog.py+7 added-1 removed
1-from flask import Blueprint, flash, g, redirect, render_template, request, url_for1+from flask import Blueprint2+from flask import flash3+from flask import g4+from flask import redirect5+from flask import render_template6+from flask import request7+from flask import url_for8 from werkzeug.exceptions import abort9 10 from flaskr.auth import login_required11 from flaskr.db import get_db114 unmodified linesmodified:examples/tutorial/flaskr/db.py+2 added-1 removed
1 import sqlite32 3 import click4-from flask import current_app, g4+from flask import current_app5+from flask import g6 from flask.cli import with_appcontext7 8 9 def get_db():45 unmodified linesmodified:examples/tutorial/tests/conftest.py+3 added-1 removed
1 import os2 import tempfile3 4 import pytest5+6 from flaskr import create_app6-from flaskr.db import get_db, init_db7+from flaskr.db import get_db8+from flaskr.db import init_db9 10 # read in SQL for populating test data11 with open(os.path.join(os.path.dirname(__file__), "data.sql"), "rb") as f:12 _data_sql = f.read().decode("utf8")50 unmodified linesmodified:examples/tutorial/tests/test_auth.py+3 added-1 removed
1 import pytest2-from flask import g, session2+from flask import g3+from flask import session4+5 from flaskr.db import get_db6 7 8 def test_register(client, app):61 unmodified linesmodified:examples/tutorial/tests/test_blog.py+1 added
1 import pytest2+3 from flaskr.db import get_db4 5 6 def test_index(client, auth):77 unmodified linesmodified:examples/tutorial/tests/test_db.py+1 added
1 import sqlite32 3 import pytest4+5 from flaskr.db import get_db6 7 8 def test_get_close_db(app):21 unmodified linesmodified:examples/tutorial/setup.py+2 added-1 removed
1 import io2 3-from setuptools import find_packages, setup3+from setuptools import find_packages4+from setuptools import setup5 6 with io.open("README.rst", "rt", encoding="utf8") as f:7 readme = f.read()8 15 unmodified linesmodified:scripts/make-release.py+4 added-2 removed
2 unmodified lines3 4 import os5 import re6 import sys7-from datetime import date, datetime8-from subprocess import PIPE, Popen7+from datetime import date8+from datetime import datetime9+from subprocess import PIPE10+from subprocess import Popen11 12 _date_strip_re = re.compile(r"(?<=\d)(st|nd|rd|th)")13 14 150 unmodified linesmodified:src/flask/json/__init__.py+8 added-7 removed
7 unmodified lines8 """9 import codecs10 import io11 import uuid12-from datetime import date, datetime13-from flask.globals import current_app, request14-from flask._compat import text_type, PY212+from datetime import date13+from datetime import datetime14 16-from werkzeug.http import http_date15+from itsdangerous import json as _json16 from jinja2 import Markup17+from werkzeug.http import http_date18 19-# Use the same json implementation as itsdangerous on which we20-# depend anyways.21-from itsdangerous import json as _json19+from .._compat import PY220+from .._compat import text_type21+from ..globals import current_app22+from ..globals import request23 24 try:25 import dataclasses26 except ImportError:350 unmodified linesmodified:src/flask/json/tag.py+8 added-5 removed
39 unmodified lines40 41 :copyright: © 2010 by the Pallets team.42 :license: BSD, see LICENSE for more details.43 """44-45-from base64 import b64decode, b64encode44+from base64 import b64decode45+from base64 import b64encode46 from datetime import datetime47 from uuid import UUID48 49 from jinja2 import Markup50-from werkzeug.http import http_date, parse_date50+from werkzeug.http import http_date51+from werkzeug.http import parse_date52 52-from flask._compat import iteritems, text_type53-from flask.json import dumps, loads53+from .._compat import iteritems54+from .._compat import text_type55+from ..json import dumps56+from ..json import loads57 58 59 class JSONTag(object):60 """Base class for defining type tags for :class:`TaggedJSONSerializer`."""249 unmodified linesmodified:src/flask/__init__.py+41 added-54 removed
7 unmodified lines8 9 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11 """12-13-__version__ = "1.1.dev"14-12 # utilities we import from Werkzeug and Jinja2 that are unused13 # in the module but are exported as public interface.14+from jinja2 import escape15+from jinja2 import Markup16 from werkzeug.exceptions import abort17 from werkzeug.utils import redirect19-from jinja2 import Markup, escape18 21-from .app import Flask, Request, Response22-from .config import Config23-from .helpers import (24- url_for,25- flash,26- send_file,27- send_from_directory,28- get_flashed_messages,29- get_template_attribute,30- make_response,31- safe_join,32- stream_with_context,33-)34-from .globals import (35- current_app,36- g,37- request,38- session,39- _request_ctx_stack,40- _app_ctx_stack,41-)42-from .ctx import (43- has_request_context,44- has_app_context,45- after_this_request,46- copy_current_request_context,47-)19+from . import json20+from .app import Flask21+from .app import Request22+from .app import Response23 from .blueprints import Blueprint24+from .config import Config25+from .ctx import after_this_request26+from .ctx import copy_current_request_context27+from .ctx import has_app_context28+from .ctx import has_request_context29+from .globals import _app_ctx_stack30+from .globals import _request_ctx_stack31+from .globals import current_app32+from .globals import g33+from .globals import request34+from .globals import session35+from .helpers import flash36+from .helpers import get_flashed_messages37+from .helpers import get_template_attribute38+from .helpers import make_response39+from .helpers import safe_join40+from .helpers import send_file41+from .helpers import send_from_directory42+from .helpers import stream_with_context43+from .helpers import url_for44+from .json import jsonify45+from .signals import appcontext_popped46+from .signals import appcontext_pushed47+from .signals import appcontext_tearing_down48+from .signals import before_render_template49+from .signals import got_request_exception50+from .signals import message_flashed51+from .signals import request_finished52+from .signals import request_started53+from .signals import request_tearing_down54+from .signals import signals_available55+from .signals import template_rendered56+from .templating import render_template49-from .templating import render_template, render_template_string57+from .templating import render_template_string58 51-# the signals52-from .signals import (53- signals_available,54- template_rendered,55- request_started,56- request_finished,57- got_request_exception,58- request_tearing_down,59- appcontext_tearing_down,60- appcontext_pushed,61- appcontext_popped,62- message_flashed,63- before_render_template,64-)65-66-# We're not exposing the actual json module but a convenient wrapper around67-# it.68-from . import json69-70-# This was the only thing that Flask used to export at one point and it had71-# a more generic name.72-jsonify = json.jsonify59+__version__ = "1.1.dev"modified:src/flask/_compat.py-1 removed
8 unmodified lines9 10 :copyright: © 2010 by the Pallets team.11 :license: BSD, see LICENSE for more details.12 """13-13 import sys14 15 PY2 = sys.version_info[0] == 216 _identity = lambda x: x99 unmodified linesmodified:src/flask/app.py+50 added-43 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import os12 import sys13 import warnings14 from datetime import timedelta15 from functools import update_wrapper16 from itertools import chain17 from threading import Lock18 20-from werkzeug.datastructures import Headers, ImmutableDict21-from werkzeug.exceptions import (22- BadRequest,23- BadRequestKeyError,24- HTTPException,25- InternalServerError,26- MethodNotAllowed,27- default_exceptions,28-)29-from werkzeug.routing import BuildError, Map, RequestRedirect, RoutingException, Rule19+from werkzeug.datastructures import Headers20+from werkzeug.datastructures import ImmutableDict21+from werkzeug.exceptions import BadRequest22+from werkzeug.exceptions import BadRequestKeyError23+from werkzeug.exceptions import default_exceptions24+from werkzeug.exceptions import HTTPException25+from werkzeug.exceptions import InternalServerError26+from werkzeug.exceptions import MethodNotAllowed27+from werkzeug.routing import BuildError28+from werkzeug.routing import Map29+from werkzeug.routing import RequestRedirect30+from werkzeug.routing import RoutingException31+from werkzeug.routing import Rule32 from werkzeug.wrappers import BaseResponse33 32-from . import cli, json33-from ._compat import integer_types, reraise, string_types, text_type34-from .config import Config, ConfigAttribute35-from .ctx import AppContext, RequestContext, _AppCtxGlobals36-from .globals import _request_ctx_stack, g, request, session37-from .helpers import (38- _PackageBoundObject,39- _endpoint_from_view_func,40- find_package,41- get_env,42- get_debug_flag,43- get_flashed_messages,44- locked_cached_property,45- url_for,46- get_load_dotenv,47-)34+from . import cli35+from . import json36+from ._compat import integer_types37+from ._compat import reraise38+from ._compat import string_types39+from ._compat import text_type40+from .config import Config41+from .config import ConfigAttribute42+from .ctx import _AppCtxGlobals43+from .ctx import AppContext44+from .ctx import RequestContext45+from .globals import _request_ctx_stack46+from .globals import g47+from .globals import request48+from .globals import session49+from .helpers import _endpoint_from_view_func50+from .helpers import _PackageBoundObject51+from .helpers import find_package52+from .helpers import get_debug_flag53+from .helpers import get_env54+from .helpers import get_flashed_messages55+from .helpers import get_load_dotenv56+from .helpers import locked_cached_property57+from .helpers import url_for58 from .json import jsonify59 from .logging import create_logger60 from .sessions import SecureCookieSessionInterface51-from .signals import (52- appcontext_tearing_down,53- got_request_exception,54- request_finished,55- request_started,56- request_tearing_down,57-)58-from .templating import (59- DispatchingJinjaLoader,60- Environment,61- _default_template_ctx_processor,62-)63-from .wrappers import Request, Response61+from .signals import appcontext_tearing_down62+from .signals import got_request_exception63+from .signals import request_finished64+from .signals import request_started65+from .signals import request_tearing_down66+from .templating import _default_template_ctx_processor67+from .templating import DispatchingJinjaLoader68+from .templating import Environment69+from .wrappers import Request70+from .wrappers import Response71 72 # a singleton sentinel value for parameter defaults73 _sentinel = object()74 967 unmodified lines1042 the constructor of :attr:`test_client_class`.1043 """1044 cls = self.test_client_class1045 if cls is None:1039- from flask.testing import FlaskClient as cls1046+ from .testing import FlaskClient as cls1047 return cls(self, self.response_class, use_cookies=use_cookies, **kwargs)1048 1049 def test_cli_runner(self, **kwargs):1050 """Create a CLI runner for testing CLI commands.7 unmodified lines1058 """1059 cls = self.test_cli_runner_class1060 1061 if cls is None:1055- from flask.testing import FlaskCliRunner as cls1062+ from .testing import FlaskCliRunner as cls1063 1064 return cls(self, **kwargs)1065 1066 def open_session(self, request):1295 unmodified lines2362 :class:`~werkzeug.test.EnvironBuilder`.2363 :param kwargs: other keyword arguments passed to2364 :class:`~werkzeug.test.EnvironBuilder`.2365 """2359- from flask.testing import EnvironBuilder2366+ from .testing import EnvironBuilder2367 2368 builder = EnvironBuilder(self, *args, **kwargs)2369 2370 try:55 unmodified linesmodified:src/flask/blueprints.py+2 added-1 removed
9 unmodified lines10 :license: BSD, see LICENSE for more details.11 """12 from functools import update_wrapper13 14-from .helpers import _PackageBoundObject, _endpoint_from_view_func14+from .helpers import _endpoint_from_view_func15+from .helpers import _PackageBoundObject16 17 # a singleton sentinel value for parameter defaults18 _sentinel = object()19 512 unmodified linesmodified:src/flask/cli.py+13 added-7 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 from __future__ import print_function12 13 import ast14 import inspect3 unmodified lines18 import sys19 import traceback20 from functools import update_wrapper21 from operator import attrgetter23-from threading import Lock, Thread22+from threading import Lock23+from threading import Thread24 25 import click26 from werkzeug.utils import import_string27 28-from . import __version__29-from ._compat import getargspec, itervalues, reraise, text_type28+from ._compat import getargspec29+from ._compat import itervalues30+from ._compat import reraise31+from ._compat import text_type32 from .globals import current_app31-from .helpers import get_debug_flag, get_env, get_load_dotenv33+from .helpers import get_debug_flag34+from .helpers import get_env35+from .helpers import get_load_dotenv36 37 try:38 import dotenv39 except ImportError:110 unmodified lines150 function, it checks for specified arguments and whether it takes a151 ``script_info`` argument and calls the function with the appropriate152 arguments.153 """150- from flask import Flask154+ from . import Flask155 156 match = re.match(r"^ *([^ ()]+) *(?:\((.*?) *,? *\))? *$", app_name)157 158 if not match:102 unmodified lines261 262 def get_version(ctx, param, value):263 if not value or ctx.resilient_parsing:264 return265+266 import werkzeug267+ from . import __version__268 269 message = "Python %(python)s\n" "Flask %(flask)s\n" "Werkzeug %(werkzeug)s"270 click.echo(271 message598 unmodified lines870 This is useful for executing small snippets of management code871 without having to manually configure the application.872 """873 import code868- from flask.globals import _app_ctx_stack874+ from .globals import _app_ctx_stack875 876 app = _app_ctx_stack.top.app877 banner = "Python %s on %s\nApp: %s [%s]\nInstance: %s" % (878 sys.version,91 unmodified linesmodified:src/flask/config.py+4 added-3 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11+import errno12 import os13 import types14-import errno14 15 from werkzeug.utils import import_string17-from ._compat import string_types, iteritems16+17 from . import json18+from ._compat import iteritems19+from ._compat import string_types20 21 22 class ConfigAttribute(object):23 """Makes an attribute forward to the config"""246 unmodified linesmodified:src/flask/ctx.py+6 added-4 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import sys12 from functools import update_wrapper13 14 from werkzeug.exceptions import HTTPException15 17-from .globals import _request_ctx_stack, _app_ctx_stack18-from .signals import appcontext_pushed, appcontext_popped19-from ._compat import BROKEN_PYPY_CTXMGR_EXIT, reraise16+from ._compat import BROKEN_PYPY_CTXMGR_EXIT17+from ._compat import reraise18+from .globals import _app_ctx_stack19+from .globals import _request_ctx_stack20+from .signals import appcontext_popped21+from .signals import appcontext_pushed22 23 24 # a singleton sentinel value for parameter defaults25 _sentinel = object()449 unmodified linesmodified:src/flask/debughelpers.py+2 added-2 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import os12 from warnings import warn13 15-from ._compat import implements_to_string, text_type14+from ._compat import implements_to_string15+from ._compat import text_type16 from .app import Flask17 from .blueprints import Blueprint18 from .globals import _request_ctx_stack19 164 unmodified linesmodified:src/flask/globals.py+3 added-2 removed
7 unmodified lines8 9 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11 """12-12 from functools import partial14-from werkzeug.local import LocalStack, LocalProxy13 14+from werkzeug.local import LocalProxy15+from werkzeug.local import LocalStack16 17+18 _request_ctx_err_msg = """\19 Working outside of request context.20 21 This typically means that you attempted to use functionality that needed41 unmodified linesmodified:src/flask/helpers.py+21 added-13 removed
7 unmodified lines8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11 import io12+import mimetypes13 import os13-import socket14-import sys14 import pkgutil15 import posixpath17-import mimetypes18-from time import time19-from zlib import adler3220-from threading import RLock16+import socket17+import sys18 import unicodedata22-from werkzeug.routing import BuildError19 from functools import update_wrapper20+from threading import RLock21+from time import time22+from zlib import adler3223 25-from werkzeug.urls import url_quote24+from jinja2 import FileSystemLoader25 from werkzeug.datastructures import Headers27-from werkzeug.exceptions import BadRequest, NotFound, RequestedRangeNotSatisfiable28-26+from werkzeug.exceptions import BadRequest27+from werkzeug.exceptions import NotFound28+from werkzeug.exceptions import RequestedRangeNotSatisfiable29+from werkzeug.routing import BuildError30+from werkzeug.urls import url_quote31 from werkzeug.wsgi import wrap_file30-from jinja2 import FileSystemLoader32 33+from ._compat import fspath34+from ._compat import PY235+from ._compat import string_types36+from ._compat import text_type37+from .globals import _app_ctx_stack38+from .globals import _request_ctx_stack39+from .globals import current_app40+from .globals import request41+from .globals import session42 from .signals import message_flashed33-from .globals import session, _request_ctx_stack, _app_ctx_stack, current_app, request34-from ._compat import string_types, text_type, PY2, fspath43 44 # sentinel45 _missing = object()46 1077 unmodified linesmodified:src/flask/logging.py-1 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-9 from __future__ import absolute_import10 11 import logging12 import sys65 unmodified linesmodified:src/flask/sessions.py+6 added-5 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import hashlib12 import warnings13 from datetime import datetime14 16-from itsdangerous import BadSignature, URLSafeTimedSerializer15+from itsdangerous import BadSignature16+from itsdangerous import URLSafeTimedSerializer17 from werkzeug.datastructures import CallbackDict18 19-from flask._compat import collections_abc20-from flask.helpers import is_ip, total_seconds21-from flask.json.tag import TaggedJSONSerializer19+from ._compat import collections_abc20+from .helpers import is_ip21+from .helpers import total_seconds22+from .json.tag import TaggedJSONSerializer23 24 25 class SessionMixin(collections_abc.MutableMapping):26 """Expands a basic dictionary with session attributes."""362 unmodified linesmodified:src/flask/signals.py+1 added-2 removed
7 unmodified lines8 9 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11 """12-13-signals_available = False12 try:13 from blinker import Namespace14 15 signals_available = True16 except ImportError:17+ signals_available = False18 19 class Namespace(object):20 def signal(self, name, doc=None):21 return _FakeSignal(name, doc)44 unmodified linesmodified:src/flask/templating.py+7 added-4 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11+from jinja2 import BaseLoader12+from jinja2 import Environment as BaseEnvironment13+from jinja2 import TemplateNotFound14 12-from jinja2 import BaseLoader, Environment as BaseEnvironment, TemplateNotFound15+from .globals import _app_ctx_stack16+from .globals import _request_ctx_stack17+from .signals import before_render_template18+from .signals import template_rendered19 14-from .globals import _request_ctx_stack, _app_ctx_stack15-from .signals import template_rendered, before_render_template20 17-21 def _default_template_ctx_processor():22 """Default template context processor. Injects `request`,23 `session` and `g`.24 """131 unmodified linesmodified:src/flask/testing.py+5 added-5 removed
8 unmodified lines9 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11 """12 import warnings13-import werkzeug14-import werkzeug.test13 from contextlib import contextmanager14 15+import werkzeug.test16 from click.testing import CliRunner18-from flask.cli import ScriptInfo17 from werkzeug.test import Client20-from flask import _request_ctx_stack21-from flask.json import dumps as json_dumps18 from werkzeug.urls import url_parse19 20+from . import _request_ctx_stack21+from .cli import ScriptInfo22+from .json import dumps as json_dumps23 24+25 class EnvironBuilder(werkzeug.test.EnvironBuilder):26 """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the27 application.28 255 unmodified linesmodified:src/flask/views.py+1 added-2 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-12-from .globals import request11 from ._compat import with_metaclass12+from .globals import request13 14 15 http_method_funcs = frozenset(16 ["get", "post", "head", "options", "delete", "put", "trace", "patch"]147 unmodified linesmodified:src/flask/wrappers.py+4 added-4 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 from werkzeug.exceptions import BadRequest13-from werkzeug.wrappers import Request as RequestBase, Response as ResponseBase12+from werkzeug.wrappers import Request as RequestBase13+from werkzeug.wrappers import Response as ResponseBase14 from werkzeug.wrappers.json import JSONMixin as _JSONMixin15 16-from flask import json17-from flask.globals import current_app16+from . import json17+from .globals import current_app18 19 20 class JSONMixin(_JSONMixin):21 json_module = json116 unmodified linesmodified:tests/test_apps/blueprintapp/apps/admin/__init__.py+2 added-1 removed
1-from flask import Blueprint, render_template1+from flask import Blueprint2+from flask import render_template3 4 admin = Blueprint(5 "admin",6 __name__,14 unmodified linesmodified:tests/test_apps/blueprintapp/apps/frontend/__init__.py+2 added-1 removed
1-from flask import Blueprint, render_template1+from flask import Blueprint2+from flask import render_template3 4 frontend = Blueprint("frontend", __name__, template_folder="templates")5 6 8 unmodified linesmodified:tests/test_apps/cliapp/app.py+2 added-1 removed
1-from __future__ import absolute_import, print_function1+from __future__ import absolute_import2+from __future__ import print_function3 4 from flask import Flask5 6 testapp = Flask("testapp")modified:tests/test_apps/cliapp/factory.py+2 added-1 removed
1-from __future__ import absolute_import, print_function1+from __future__ import absolute_import2+from __future__ import print_function3 4 from flask import Flask5 6 14 unmodified linesmodified:tests/test_apps/cliapp/importerrorapp.py+2 added-1 removed
1-from __future__ import absolute_import, print_function1+from __future__ import absolute_import2+from __future__ import print_function3 4 from flask import Flask5 6 raise ImportError()2 unmodified linesmodified:tests/test_apps/cliapp/multiapp.py+2 added-1 removed
1-from __future__ import absolute_import, print_function1+from __future__ import absolute_import2+from __future__ import print_function3 4 from flask import Flask5 6 app1 = Flask("app1")1 unmodified linemodified:tests/conftest.py-1 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-9 import gc10 import os11 import pkgutil12 import sys198 unmodified linesmodified:tests/test_appctx.py-1 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import pytest12 13 import flask14 206 unmodified linesmodified:tests/test_basic.py+3 added-2 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import re12 import sys13 import time14 import uuid1 unmodified line16 from threading import Thread17 18 import pytest19 import werkzeug.serving21-from werkzeug.exceptions import BadRequest, Forbidden, NotFound20+from werkzeug.exceptions import BadRequest21+from werkzeug.exceptions import Forbidden22+from werkzeug.exceptions import NotFound23 from werkzeug.http import parse_date24 from werkzeug.routing import BuildError25 26 import flask1975 unmodified linesmodified:tests/test_blueprints.py+3 added-4 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import functools12+13 import pytest14+from jinja2 import TemplateNotFound15+from werkzeug.http import parse_cache_control_header16 17 import flask16-18 from flask._compat import text_type18-from werkzeug.http import parse_cache_control_header19-from jinja2 import TemplateNotFound19 20 21 def test_blueprint_specific_error_handling(app, client):22 frontend = flask.Blueprint("frontend", __name__)841 unmodified linesmodified:tests/test_cli.py+15 added-17 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-9 # This file was part of Flask-CLI and was modified under the terms of10 # its Revised BSD License. Copyright © 2015 CERN.12-11 from __future__ import absolute_import12 13 import os14 import ssl5 unmodified lines20 import pytest21 from _pytest.monkeypatch import notset22 from click.testing import CliRunner23 26-from flask import Flask, current_app, Blueprint27-from flask.cli import (28- AppGroup,29- FlaskGroup,30- NoAppException,31- ScriptInfo,32- dotenv,33- find_best_app,34- get_version,35- load_dotenv,36- locate_app,37- prepare_import,38- run_command,39- with_appcontext,40-)24+from flask import Blueprint25+from flask import current_app26+from flask import Flask27+from flask.cli import AppGroup28+from flask.cli import dotenv29+from flask.cli import find_best_app30+from flask.cli import FlaskGroup31+from flask.cli import get_version32+from flask.cli import load_dotenv33+from flask.cli import locate_app34+from flask.cli import NoAppException35+from flask.cli import prepare_import36+from flask.cli import run_command37+from flask.cli import ScriptInfo38+from flask.cli import with_appcontext39 40 cwd = os.getcwd()41 test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "test_apps"))42 625 unmodified linesmodified:tests/test_config.py+3 added-3 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-10-from datetime import timedelta9 import os10 import textwrap11+from datetime import timedelta12 13+import pytest14+15 import flask16 from flask._compat import PY216-import pytest17 18 19 # config keys used for the TestConfig20 TEST_KEY = "foo"182 unmodified linesmodified:tests/test_helpers.py+9 added-5 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import datetime12 import io13 import os14 import uuid15 16 import pytest17 from werkzeug.datastructures import Range19-from werkzeug.exceptions import BadRequest, NotFound20-from werkzeug.http import http_date, parse_cache_control_header, parse_options_header18+from werkzeug.exceptions import BadRequest19+from werkzeug.exceptions import NotFound20+from werkzeug.http import http_date21+from werkzeug.http import parse_cache_control_header22+from werkzeug.http import parse_options_header23 24 import flask25 from flask import json24-from flask._compat import StringIO, text_type25-from flask.helpers import get_debug_flag, get_env26+from flask._compat import StringIO27+from flask._compat import text_type28+from flask.helpers import get_debug_flag29+from flask.helpers import get_env30 31 32 def has_encoding(name):33 try:1009 unmodified linesmodified:tests/test_instance_config.py+1 added-1 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-9 import os10 import sys11 12 import pytest13+14 import flask15 from flask._compat import PY216 17 126 unmodified linesmodified:tests/test_json_tag.py+2 added-2 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-9 from datetime import datetime10 from uuid import uuid411 12 import pytest13 14 from flask import Markup16-from flask.json.tag import TaggedJSONSerializer, JSONTag15+from flask.json.tag import JSONTag16+from flask.json.tag import TaggedJSONSerializer17 18 19 @pytest.mark.parametrize(20 "data",73 unmodified linesmodified:tests/test_logging.py+3 added-2 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9-9 import logging10 import sys11 12 import pytest13 14 from flask._compat import StringIO16-from flask.logging import default_handler, has_level_handler, wsgi_errors_stream15+from flask.logging import default_handler16+from flask.logging import has_level_handler17+from flask.logging import wsgi_errors_stream18 19 20 @pytest.fixture(autouse=True)21 def reset_logging(pytestconfig):85 unmodified linesmodified:tests/test_regression.py-1 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import gc12 import sys13 import threading14 83 unmodified linesmodified:tests/test_reqctx.py-1 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import pytest12 13 import flask14 from flask.sessions import SessionInterface276 unmodified linesmodified:tests/test_signals.py-1 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import pytest12 13 try:14 import blinker192 unmodified linesmodified:tests/test_subclassing.py-2 removed
7 unmodified lines8 9 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11 """12-12 import flask14-13 from flask._compat import StringIO14 15 16 def test_suppressed_exception_logging():15 unmodified linesmodified:tests/test_templating.py+3 added-3 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11+import logging12 13 import pytest14+import werkzeug.serving15+from jinja2 import TemplateNotFound16 17 import flask15-import logging16-from jinja2 import TemplateNotFound17-import werkzeug.serving18 19 20 def test_context_processing(app, client):21 @app.context_processor430 unmodified linesmodified:tests/test_testing.py+4 added-3 removed
8 unmodified lines9 :license: BSD, see LICENSE for more details.10 """11 import click12 import pytest13-14-import flask13 import werkzeug14 15+import flask16 from flask import appcontext_popped17 from flask._compat import text_type18 from flask.cli import ScriptInfo19 from flask.json import jsonify21-from flask.testing import make_test_environ_builder, FlaskCliRunner, EnvironBuilder20+from flask.testing import EnvironBuilder21+from flask.testing import FlaskCliRunner22+from flask.testing import make_test_environ_builder23 24 try:25 import blinker26 except ImportError:419 unmodified linesmodified:tests/test_user_error_handler.py+4 added-1 removed
4 unmodified lines5 6 :copyright: © 2010 by the Pallets team.7 :license: BSD, see LICENSE for more details.8 """9+from werkzeug.exceptions import Forbidden10+from werkzeug.exceptions import HTTPException11+from werkzeug.exceptions import InternalServerError12+from werkzeug.exceptions import NotFound13 10-from werkzeug.exceptions import Forbidden, InternalServerError, HTTPException, NotFound14 import flask15 16 17 def test_error_handler_no_match(app, client):179 unmodified linesmodified:tests/test_views.py-2 removed
6 unmodified lines7 8 :copyright: © 2010 by the Pallets team.9 :license: BSD, see LICENSE for more details.10 """11-11 import pytest12 from werkzeug.http import parse_set_header13 15-import flask14 import flask.views15 16 17 def common_test(app):235 unmodified linesmodified:.pre-commit-config.yaml+8 added-1 removed
1 repos:2+ - repo: https://github.com/asottile/reorder_python_imports3+ rev: v1.4.04+ hooks:5+ - id: reorder-python-imports6+ name: Reorder Python imports (src, tests)7+ files: "^(?!examples/)"8+ args: ["--application-directories", ".:src"]9 - repo: https://github.com/python/black10 rev: 19.3b011 hooks:12 - id: black2 unmodified lines15 hooks:16 - id: flake817 additional_dependencies: [flake8-bugbear]18 - repo: https://github.com/pre-commit/pre-commit-hooks12- rev: v2.1.019+ rev: v2.2.320 hooks:21 - id: check-byte-order-marker22 - id: trailing-whitespace23 - id: end-of-file-fixer