summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2020-04-19 23:54:14 -0700
committerDavid Lord <davidism@gmail.com>2020-04-20 07:12:53 -0700
commit9897d81d0830f2048360cbd45993de1b37ce7371 (patch)
tree1ae0d18e075740b808c69167e97583fde9dd55e3 /examples
parentb444e6355ec50417546f42138bb833d1e9e8b306 (diff)
downloadclick-9897d81d0830f2048360cbd45993de1b37ce7371.tar.gz
f-strings everywhere
Diffstat (limited to 'examples')
-rw-r--r--examples/aliases/aliases.py2
-rw-r--r--examples/bashcompletion/bashcompletion.py2
-rw-r--r--examples/complex/complex/commands/cmd_init.py2
-rw-r--r--examples/imagepipe/imagepipe.py5
-rw-r--r--examples/repo/repo.py2
-rw-r--r--examples/termui/termui.py2
-rw-r--r--examples/validation/validation.py3
7 files changed, 8 insertions, 10 deletions
diff --git a/examples/aliases/aliases.py b/examples/aliases/aliases.py
index c01672b..c3da657 100644
--- a/examples/aliases/aliases.py
+++ b/examples/aliases/aliases.py
@@ -65,7 +65,7 @@ class AliasedGroup(click.Group):
return None
elif len(matches) == 1:
return click.Group.get_command(self, ctx, matches[0])
- ctx.fail("Too many matches: {}".format(", ".join(sorted(matches))))
+ ctx.fail(f"Too many matches: {', '.join(sorted(matches))}")
def read_config(ctx, param, value):
diff --git a/examples/bashcompletion/bashcompletion.py b/examples/bashcompletion/bashcompletion.py
index 592bf19..3f8c9df 100644
--- a/examples/bashcompletion/bashcompletion.py
+++ b/examples/bashcompletion/bashcompletion.py
@@ -19,7 +19,7 @@ def get_env_vars(ctx, args, incomplete):
@click.argument("envvar", type=click.STRING, autocompletion=get_env_vars)
def cmd1(envvar):
click.echo(f"Environment variable: {envvar}")
- click.echo("Value: {}".format(os.environ[envvar]))
+ click.echo(f"Value: {os.environ[envvar]}")
@click.group(help="A group that holds a subcommand")
diff --git a/examples/complex/complex/commands/cmd_init.py b/examples/complex/complex/commands/cmd_init.py
index c2cf770..8802458 100644
--- a/examples/complex/complex/commands/cmd_init.py
+++ b/examples/complex/complex/commands/cmd_init.py
@@ -10,4 +10,4 @@ def cli(ctx, path):
"""Initializes a repository."""
if path is None:
path = ctx.home
- ctx.log("Initialized the repository in %s", click.format_filename(path))
+ ctx.log(f"Initialized the repository in {click.format_filename(path)}")
diff --git a/examples/imagepipe/imagepipe.py b/examples/imagepipe/imagepipe.py
index 95f5c42..57432fa 100644
--- a/examples/imagepipe/imagepipe.py
+++ b/examples/imagepipe/imagepipe.py
@@ -230,9 +230,8 @@ def smoothen_cmd(images, iterations):
"""Applies a smoothening filter."""
for image in images:
click.echo(
- "Smoothening '{}' {} time{}".format(
- image.filename, iterations, "s" if iterations != 1 else ""
- )
+ f"Smoothening {image.filename!r} {iterations}"
+ f" time{'s' if iterations != 1 else ''}"
)
for _ in range(iterations):
image = copy_filename(image.filter(ImageFilter.BLUR), image)
diff --git a/examples/repo/repo.py b/examples/repo/repo.py
index ff44d55..b773f3a 100644
--- a/examples/repo/repo.py
+++ b/examples/repo/repo.py
@@ -78,7 +78,7 @@ def clone(repo, src, dest, shallow, rev):
"""
if dest is None:
dest = posixpath.split(src)[-1] or "."
- click.echo("Cloning repo {} to {}".format(src, os.path.abspath(dest)))
+ click.echo(f"Cloning repo {src} to {os.path.basename(dest)}")
repo.home = dest
if shallow:
click.echo("Making shallow checkout")
diff --git a/examples/termui/termui.py b/examples/termui/termui.py
index b772f13..f4886b1 100644
--- a/examples/termui/termui.py
+++ b/examples/termui/termui.py
@@ -24,7 +24,7 @@ def pager():
"""Demonstrates using the pager."""
lines = []
for x in range(200):
- lines.append("{}. Hello World!".format(click.style(str(x), fg="green")))
+ lines.append(f"{click.style(str(x), fg='green')}. Hello World!")
click.echo_via_pager("\n".join(lines))
diff --git a/examples/validation/validation.py b/examples/validation/validation.py
index 6f87eb0..3f78df0 100644
--- a/examples/validation/validation.py
+++ b/examples/validation/validation.py
@@ -17,8 +17,7 @@ class URL(click.ParamType):
value = urlparse.urlparse(value)
if value.scheme not in ("http", "https"):
self.fail(
- "invalid URL scheme ({}). Only HTTP URLs are"
- " allowed".format(value.scheme),
+ f"invalid URL scheme ({value.scheme}). Only HTTP URLs are allowed",
param,
ctx,
)