Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CLI output when running post_write hooks #1262

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions alembic/script/write_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _invoke(
hook = _registry[name]
except KeyError as ke:
raise util.CommandError(
"No formatter with name '%s' registered" % name
f"No formatter with name '{name}' registered"
) from ke
else:
return hook(revision, options)
Expand All @@ -82,10 +82,12 @@ def _run_hooks(path: str, hook_config: Mapping[str, str]) -> None:
type_ = opts["type"]
except KeyError as ke:
raise util.CommandError(
"Key %s.type is required for post write hook %r" % (name, name)
f"Key {name}.type is required for post write hook {name!r}"
) from ke
else:
with util.status("Running post write hook {name!r}", newline=True):
with util.status(
f"Running post write hook {name!r}", newline=True
):
_invoke(type_, path, opts)


Expand Down Expand Up @@ -118,8 +120,8 @@ def console_scripts(
entrypoint_name = options["entrypoint"]
except KeyError as ke:
raise util.CommandError(
"Key %s.entrypoint is required for post write hook %r"
% (options["_hook_name"], options["_hook_name"])
f"Key {options['_hook_name']}.entrypoint is required for post "
f"write hook {options['_hook_name']!r}"
) from ke
for entry in compat.importlib_metadata_get("console_scripts"):
if entry.name == entrypoint_name:
Expand All @@ -141,7 +143,7 @@ def console_scripts(
[
sys.executable,
"-c",
"import %s; %s.%s()" % (impl.module, impl.module, impl.attr),
f"import {impl.module}; {impl.module}.{impl.attr}()",
]
+ cmdline_options_list,
cwd=cwd,
Expand Down