Update format strings to f strings

master
James Curtin 5 years ago committed by James Curtin
parent 424cc853ee
commit 902c49c734
  1. 2
      Dockerfile
  2. 2
      cookiecutter-docker.sh
  3. 20
      cookiecutter.json
  4. 2
      hooks/pre_gen_project.py
  5. 4
      {{cookiecutter.app_name}}/tests/factories.py
  6. 2
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py
  7. 2
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/commands.py
  8. 4
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/database.py
  9. 6
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/user/models.py
  10. 2
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/utils.py

@ -1,4 +1,4 @@
FROM python:3.7-slim-buster
FROM python:3.8-slim-buster
RUN pip install \
cookiecutter==1.6.0

@ -62,5 +62,3 @@ run_cookiecutter() {
process_args "$@"
run_cookiecutter
exit 0

@ -1,12 +1,12 @@
{
"full_name": "Steven Loria",
"email": "sloria1@gmail.com",
"github_username": "sloria",
"project_name": "My Flask App",
"app_name": "{{cookiecutter.project_name.lower().replace('-', '_').replace(' ', '_')}}",
"project_short_description": "A flasky app.",
"use_pipenv": ["no", "yes"],
"python_version": ["3.7", "3.6"],
"node_version": ["12", "10", "8"],
"use_heroku": ["no", "yes"]
"full_name": "Steven Loria",
"email": "sloria1@gmail.com",
"github_username": "sloria",
"project_name": "My Flask App",
"app_name": "{{cookiecutter.project_name.lower().replace('-', '_').replace(' ', '_')}}",
"project_short_description": "A flasky app.",
"use_pipenv": ["no", "yes"],
"python_version": ["3.8", "3.7", "3.6"],
"node_version": ["12", "10"],
"use_heroku": ["no", "yes"]
}

@ -31,7 +31,7 @@ def validate_python_module_name():
module_name = "{{ cookiecutter.app_name }}"
if not re.match(MODULE_REGEX, module_name):
log_warning(module_name)
raise ValueError
sys.exit(1)
if __name__ == "__main__":

@ -20,8 +20,8 @@ class BaseFactory(SQLAlchemyModelFactory):
class UserFactory(BaseFactory):
"""User factory."""
username = Sequence(lambda n: "user{0}".format(n))
email = Sequence(lambda n: "user{0}@example.com".format(n))
username = Sequence(lambda n: f"user{n}")
email = Sequence(lambda n: f"user{n}@example.com")
password = PostGenerationMethodCall("set_password", "example")
active = True

@ -61,7 +61,7 @@ def register_errorhandlers(app):
"""Render error template."""
# If a HTTPException, pull the `code` attribute; default to 500
error_code = getattr(error, "code", 500)
return render_template("{0}.html".format(error_code)), error_code
return render_template(f"{error_code}.html"), error_code
for errcode in [401, 404, 500]:
app.errorhandler(errcode)(render_error)

@ -49,7 +49,7 @@ def lint(fix_imports, check):
def execute_tool(description, *args):
"""Execute a checking tool with its arguments."""
command_line = list(args) + files_and_directories
click.echo("{}: {}".format(description, " ".join(command_line)))
click.echo(f"{description}: {' '.join(command_line)}")
rv = call(command_line)
if rv != 0:
exit(rv)

@ -78,7 +78,7 @@ def reference_col(
column_kwargs = column_kwargs or {}
return Column(
db.ForeignKey("{0}.{1}".format(tablename, pk_name), **foreign_key_kwargs),
db.ForeignKey(f"{tablename}.{pk_name}", **foreign_key_kwargs),
nullable=nullable,
**column_kwargs
**column_kwargs,
)

@ -29,7 +29,7 @@ class Role(SurrogatePK, Model):
def __repr__(self):
"""Represent instance as a unique string."""
return "<Role({name})>".format(name=self.name)
return f"<Role({self.name})>"
class User(UserMixin, SurrogatePK, Model):
@ -65,8 +65,8 @@ class User(UserMixin, SurrogatePK, Model):
@property
def full_name(self):
"""Full user name."""
return "{0} {1}".format(self.first_name, self.last_name)
return f"{self.first_name} {self.last_name}"
def __repr__(self):
"""Represent instance as a unique string."""
return "<User({username!r})>".format(username=self.username)
return f"<User({self.username!r})>"

@ -7,4 +7,4 @@ def flash_errors(form, category="warning"):
"""Flash all errors for a form."""
for field, errors in form.errors.items():
for error in errors:
flash("{0} - {1}".format(getattr(form, field).label.text, error), category)
flash(f"{getattr(form, field).label.text} - {error}", category)

Loading…
Cancel
Save