mirror of https://github.com/pallets/flask.git
Remove six dependency
This commit is contained in:
parent
135c53a5f2
commit
a0801719f8
|
|
@ -24,7 +24,6 @@ from functools import update_wrapper
|
|||
|
||||
from werkzeug.datastructures import Headers
|
||||
from werkzeug.exceptions import NotFound
|
||||
import six
|
||||
from flask._compat import string_types, text_type
|
||||
|
||||
# this was moved in 0.7
|
||||
|
|
@ -128,7 +127,7 @@ def stream_with_context(generator_or_function):
|
|||
# pushed. This item is discarded. Then when the iteration continues the
|
||||
# real generator is executed.
|
||||
wrapped_g = generator()
|
||||
six.advance_iterator(wrapped_g)
|
||||
next(wrapped_g)
|
||||
return wrapped_g
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
import uuid
|
||||
from datetime import datetime
|
||||
from .globals import current_app, request
|
||||
from ._compat import text_type
|
||||
|
||||
from werkzeug.http import http_date
|
||||
|
||||
# Use the same json implementation as itsdangerous on which we
|
||||
# depend anyways.
|
||||
from itsdangerous import json as _json
|
||||
import six
|
||||
|
||||
|
||||
# figure out if simplejson escapes slashes. This behavior was changed
|
||||
|
|
@ -60,7 +60,7 @@ class JSONEncoder(_json.JSONEncoder):
|
|||
if isinstance(o, uuid.UUID):
|
||||
return str(o)
|
||||
if hasattr(o, '__html__'):
|
||||
return six.text_type(o.__html__())
|
||||
return text_type(o.__html__())
|
||||
return _json.JSONEncoder.default(self, o)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from jinja2 import BaseLoader, Environment as BaseEnvironment, \
|
|||
from .globals import _request_ctx_stack, _app_ctx_stack
|
||||
from .signals import template_rendered
|
||||
from .module import blueprint_is_module
|
||||
import six
|
||||
from ._compat import itervalues, iteritems
|
||||
|
||||
|
||||
def _default_template_ctx_processor():
|
||||
|
|
@ -80,7 +80,7 @@ class DispatchingJinjaLoader(BaseLoader):
|
|||
except (ValueError, KeyError):
|
||||
pass
|
||||
|
||||
for blueprint in six.itervalues(self.app.blueprints):
|
||||
for blueprint in itervalues(self.app.blueprints):
|
||||
if blueprint_is_module(blueprint):
|
||||
continue
|
||||
loader = blueprint.jinja_loader
|
||||
|
|
@ -93,7 +93,7 @@ class DispatchingJinjaLoader(BaseLoader):
|
|||
if loader is not None:
|
||||
result.update(loader.list_templates())
|
||||
|
||||
for name, blueprint in six.iteritems(self.app.blueprints):
|
||||
for name, blueprint in iteritems(self.app.blueprints):
|
||||
loader = blueprint.jinja_loader
|
||||
if loader is not None:
|
||||
for template in loader.list_templates():
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ import unittest
|
|||
from datetime import datetime
|
||||
from threading import Thread
|
||||
from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning
|
||||
from flask._compat import text_type
|
||||
from werkzeug.exceptions import BadRequest, NotFound
|
||||
from werkzeug.http import parse_date
|
||||
from werkzeug.routing import BuildError
|
||||
import six
|
||||
|
||||
|
||||
class BasicFunctionalityTestCase(FlaskTestCase):
|
||||
|
|
@ -276,7 +276,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
|||
|
||||
@app.route('/test')
|
||||
def test():
|
||||
return six.text_type(flask.session.permanent)
|
||||
return text_type(flask.session.permanent)
|
||||
|
||||
client = app.test_client()
|
||||
rv = client.get('/')
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ import flask
|
|||
import unittest
|
||||
import warnings
|
||||
from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning
|
||||
from flask._compat import text_type
|
||||
from werkzeug.exceptions import NotFound
|
||||
from werkzeug.http import parse_cache_control_header
|
||||
from jinja2 import TemplateNotFound
|
||||
import six
|
||||
|
||||
|
||||
# import moduleapp here because it uses deprecated features and we don't
|
||||
|
|
@ -303,7 +303,7 @@ class BlueprintTestCase(FlaskTestCase):
|
|||
|
||||
@bp.route('/bar')
|
||||
def bar(bar):
|
||||
return six.text_type(bar)
|
||||
return text_type(bar)
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.register_blueprint(bp, url_prefix='/1', url_defaults={'bar': 23})
|
||||
|
|
|
|||
|
|
@ -11,9 +11,12 @@
|
|||
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
from imp import reload as reload_module
|
||||
except ImportError:
|
||||
reload_module = reload
|
||||
from flask.testsuite import FlaskTestCase
|
||||
from flask._compat import PY2
|
||||
from six.moves import reload_module
|
||||
|
||||
class ExtImportHookTestCase(FlaskTestCase):
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ import unittest
|
|||
from logging import StreamHandler
|
||||
from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr
|
||||
from werkzeug.http import parse_cache_control_header, parse_options_header
|
||||
import six
|
||||
from flask._compat import StringIO
|
||||
from flask._compat import StringIO, text_type
|
||||
|
||||
|
||||
def has_encoding(name):
|
||||
|
|
@ -34,7 +33,7 @@ class JSONTestCase(FlaskTestCase):
|
|||
app = flask.Flask(__name__)
|
||||
@app.route('/json', methods=['POST'])
|
||||
def return_json():
|
||||
return six.text_type(flask.request.json)
|
||||
return text_type(flask.request.json)
|
||||
c = app.test_client()
|
||||
rv = c.post('/json', data='malformed', content_type='application/json')
|
||||
self.assert_equal(rv.status_code, 400)
|
||||
|
|
@ -43,7 +42,7 @@ class JSONTestCase(FlaskTestCase):
|
|||
app = flask.Flask(__name__)
|
||||
@app.route('/json', methods=['POST'])
|
||||
def return_json():
|
||||
return six.text_type(flask.request.json)
|
||||
return text_type(flask.request.json)
|
||||
c = app.test_client()
|
||||
rv = c.post('/json', data='malformed', content_type='application/json')
|
||||
self.assert_equal(rv.status_code, 400)
|
||||
|
|
@ -95,7 +94,7 @@ class JSONTestCase(FlaskTestCase):
|
|||
app = flask.Flask(__name__)
|
||||
@app.route('/add', methods=['POST'])
|
||||
def add():
|
||||
return six.text_type(flask.request.json['a'] + flask.request.json['b'])
|
||||
return text_type(flask.request.json['a'] + flask.request.json['b'])
|
||||
c = app.test_client()
|
||||
rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}),
|
||||
content_type='application/json')
|
||||
|
|
@ -506,7 +505,7 @@ class StreamingTestCase(FlaskTestCase):
|
|||
def close(self):
|
||||
called.append(42)
|
||||
def next(self):
|
||||
return six.advance_iterator(self._gen)
|
||||
return next(self._gen)
|
||||
@app.route('/')
|
||||
def index():
|
||||
def generate():
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
import flask
|
||||
import unittest
|
||||
from flask.testsuite import FlaskTestCase
|
||||
import six
|
||||
from flask._compat import text_type
|
||||
|
||||
|
||||
class TestToolsTestCase(FlaskTestCase):
|
||||
|
|
@ -84,7 +84,7 @@ class TestToolsTestCase(FlaskTestCase):
|
|||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return six.text_type(flask.session['foo'])
|
||||
return text_type(flask.session['foo'])
|
||||
|
||||
with app.test_client() as c:
|
||||
with c.session_transaction() as sess:
|
||||
|
|
|
|||
Loading…
Reference in New Issue