Skip to content

Commit

Permalink
Convert 'format' usage to f-strings (cli.py)
Browse files Browse the repository at this point in the history
  • Loading branch information
insspb committed Jun 8, 2022
1 parent 24472a8 commit 37da8d8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions cookiecutter/cli.py
Expand Up @@ -27,17 +27,16 @@ def version_msg():
"""Return the Cookiecutter version, location and Python powering it."""
python_version = sys.version
location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
message = 'Cookiecutter %(version)s from {} (Python {})'
return message.format(location, python_version)
return f"Cookiecutter {__version__} from {location} (Python {python_version})"


def validate_extra_context(ctx, param, value):
"""Validate extra context."""
for s in value:
if '=' not in s:
for string in value:
if '=' not in string:
raise click.BadParameter(
'EXTRA_CONTEXT should contain items of the form key=value; '
"'{}' doesn't match that form".format(s)
f"EXTRA_CONTEXT should contain items of the form key=value; "
f"'{string}' doesn't match that form"
)

# Convert tuple -- e.g.: ('program_name=foobar', 'startsecs=66')
Expand All @@ -51,8 +50,8 @@ def list_installed_templates(default_config, passed_config_file):
cookiecutter_folder = config.get('cookiecutters_dir')
if not os.path.exists(cookiecutter_folder):
click.echo(
'Error: Cannot list installed templates. Folder does not exist: '
'{}'.format(cookiecutter_folder)
f"Error: Cannot list installed templates. "
f"Folder does not exist: {cookiecutter_folder}"
)
sys.exit(-1)

Expand Down

0 comments on commit 37da8d8

Please sign in to comment.