Skip to content
Myr

Merge pull request #3406 from erfanio/f-string-docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Change docs to use f-strings

authored by David Lord · committed by GitHub · parents b5d9084, 07caa44 · Browse files · 7 files+13 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+13 added−13 removed

  • other:+13 added−13 removed

7 files+13 added−13 removed

modified:docs/patterns/fabric.rst+4 added-4 removed
47 unmodified lines
4849 def deploy():50 # figure out the package name and version51 dist = local('python setup.py --fullname', capture=True).strip()52 filename = '%s.tar.gz' % dist52 filename = f'{dist}.tar.gz'5354 # upload the package to the temporary folder on the server55 put('dist/%s' % filename, '/tmp/%s' % filename)55 put(f'dist/{filename}', f'/tmp/{filename}')5657 # install the package in the application's virtualenv with pip58 run('/var/www/yourapplication/env/bin/pip install /tmp/%s' % filename)58 run(f'/var/www/yourapplication/env/bin/pip install /tmp/{filename}')5960 # remove the uploaded package61 run('rm -r /tmp/%s' % filename)61 run(f'rm -r /tmp/{filename}')6263 # touch the .wsgi file to trigger a reload in mod_wsgi64 run('touch /var/www/yourapplication.wsgi')65
121 unmodified lines
modified:docs/patterns/sqlalchemy.rst+2 added-2 removed
84 unmodified lines
85 self.name = name86 self.email = email8788 def __repr__(self):89 return '<User %r>' % (self.name)89 return f'<User {self.name!r}>'9091To create the database you can use the `init_db` function:9293>>> from yourapplication.database import init_db
64 unmodified lines
158 self.name = name159 self.email = email160161 def __repr__(self):162 return '<User %r>' % (self.name)162 return f'<User {self.name!r}>'163164 users = Table('users', metadata,165 Column('id', Integer, primary_key=True),166 Column('name', String(50), unique=True),
52 unmodified lines
modified:docs/patterns/viewdecorators.rst+2 added-2 removed
80 unmodified lines
8182 from functools import wraps83 from flask import request8485 def cached(timeout=5 * 60, key='view/%s'):85 def cached(timeout=5 * 60, key='view/{}'):86 def decorator(f):87 @wraps(f)88 def decorated_function(*args, **kwargs):89 cache_key = key % request.path89 cache_key = key.format(request.path)90 rv = cache.get(cache_key)91 if rv is not None:92 return rv93 rv = f(*args, **kwargs)
79 unmodified lines
modified:docs/blueprints.rst+1 added-1 removed
68 unmodified lines
69 @simple_page.route('/', defaults={'page': 'index'})70 @simple_page.route('/<page>')71 def show(page):72 try:73 return render_template('pages/%s.html' % page)73 return render_template(f'pages/{page}.html')74 except TemplateNotFound:75 abort(404)7677When you bind a function with the help of the ``@simple_page.route``
200 unmodified lines
modified:docs/signals.rst+1 added-1 removed
177 unmodified lines
178 from flask import template_rendered179180 @template_rendered.connect_via(app)181 def when_template_rendered(sender, template, context, **extra):182 print 'Template %s is rendered with %s' % (template.name, context)182 print f'Template {template.name} is rendered with {context}'183184Core Signals185------------186
4 unmodified lines
modified:docs/styleguide.rst+2 added-2 removed
49 unmodified lines
50 else by one. Do not use too many blank lines to separate logical51 segments in code. Example::5253 def hello(name):54 print 'Hello %s!' % name54 print f'Hello {name}!'555657 def goodbye(name):58 print 'See you %s.' % name58 print f'See you {name}.'596061 class MyClass(object):62 """This is a simple docstring"""
138 unmodified lines
modified:docs/views.rst+1 added-1 removed
229 unmodified lines
230 view_func = view.as_view(endpoint)231 app.add_url_rule(url, defaults={pk: None},232 view_func=view_func, methods=['GET',])233 app.add_url_rule(url, view_func=view_func, methods=['POST',])234 app.add_url_rule('%s<%s:%s>' % (url, pk_type, pk), view_func=view_func,234 app.add_url_rule(f'{url}<{pk_type}:{pk}>', view_func=view_func,235 methods=['GET', 'PUT', 'DELETE'])236237 register_api(UserAPI, 'user_api', '/users/', pk='user_id')