diff --git a/docs/blueprints.rst b/docs/blueprints.rst index 2e940be1..f4454752 100644 --- a/docs/blueprints.rst +++ b/docs/blueprints.rst @@ -70,7 +70,7 @@ implement a blueprint that does simple rendering of static templates:: @simple_page.route('/') def show(page): try: - return render_template('pages/%s.html' % page) + return render_template(f'pages/{page}.html') except TemplateNotFound: abort(404) diff --git a/docs/patterns/fabric.rst b/docs/patterns/fabric.rst index 941d1e26..30837931 100644 --- a/docs/patterns/fabric.rst +++ b/docs/patterns/fabric.rst @@ -49,16 +49,16 @@ virtual environment:: def deploy(): # figure out the package name and version dist = local('python setup.py --fullname', capture=True).strip() - filename = '%s.tar.gz' % dist + filename = f'{dist}.tar.gz' # upload the package to the temporary folder on the server - put('dist/%s' % filename, '/tmp/%s' % filename) + put(f'dist/{filename}', f'/tmp/{filename}') # install the package in the application's virtualenv with pip - run('/var/www/yourapplication/env/bin/pip install /tmp/%s' % filename) + run(f'/var/www/yourapplication/env/bin/pip install /tmp/{filename}') # remove the uploaded package - run('rm -r /tmp/%s' % filename) + run(f'rm -r /tmp/{filename}') # touch the .wsgi file to trigger a reload in mod_wsgi run('touch /var/www/yourapplication.wsgi') diff --git a/docs/patterns/sqlalchemy.rst b/docs/patterns/sqlalchemy.rst index e2dfcc5d..dbac44dd 100644 --- a/docs/patterns/sqlalchemy.rst +++ b/docs/patterns/sqlalchemy.rst @@ -86,7 +86,7 @@ Here is an example model (put this into :file:`models.py`, e.g.):: self.email = email def __repr__(self): - return '' % (self.name) + return f'' To create the database you can use the `init_db` function: @@ -159,7 +159,7 @@ Here is an example table and model (put this into :file:`models.py`):: self.email = email def __repr__(self): - return '' % (self.name) + return f'' users = Table('users', metadata, Column('id', Integer, primary_key=True), diff --git a/docs/patterns/viewdecorators.rst b/docs/patterns/viewdecorators.rst index c8d24a0f..2fc04bf2 100644 --- a/docs/patterns/viewdecorators.rst +++ b/docs/patterns/viewdecorators.rst @@ -82,11 +82,11 @@ Here the code:: from functools import wraps from flask import request - def cached(timeout=5 * 60, key='view/%s'): + def cached(timeout=5 * 60, key='view/{}'): def decorator(f): @wraps(f) def decorated_function(*args, **kwargs): - cache_key = key % request.path + cache_key = key.format(request.path) rv = cache.get(cache_key) if rv is not None: return rv diff --git a/docs/signals.rst b/docs/signals.rst index 2cf3ce60..7c1aef1e 100644 --- a/docs/signals.rst +++ b/docs/signals.rst @@ -179,7 +179,7 @@ With Blinker 1.1 you can also easily subscribe to signals by using the new @template_rendered.connect_via(app) def when_template_rendered(sender, template, context, **extra): - print 'Template %s is rendered with %s' % (template.name, context) + print f'Template {template.name} is rendered with {context}' Core Signals ------------ diff --git a/docs/styleguide.rst b/docs/styleguide.rst index 390d5668..c699e17f 100644 --- a/docs/styleguide.rst +++ b/docs/styleguide.rst @@ -51,11 +51,11 @@ Blank lines: segments in code. Example:: def hello(name): - print 'Hello %s!' % name + print f'Hello {name}!' def goodbye(name): - print 'See you %s.' % name + print f'See you {name}.' class MyClass(object): diff --git a/docs/views.rst b/docs/views.rst index 68e88241..ed75c027 100644 --- a/docs/views.rst +++ b/docs/views.rst @@ -231,7 +231,7 @@ registration code:: app.add_url_rule(url, defaults={pk: None}, view_func=view_func, methods=['GET',]) app.add_url_rule(url, view_func=view_func, methods=['POST',]) - app.add_url_rule('%s<%s:%s>' % (url, pk_type, pk), view_func=view_func, + app.add_url_rule(f'{url}<{pk_type}:{pk}>', view_func=view_func, methods=['GET', 'PUT', 'DELETE']) register_api(UserAPI, 'user_api', '/users/', pk='user_id')