From 693537ebe1f9a82db3773ed38172d1b653b902ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20D=C3=A9fosse?= Date: Sat, 17 Jun 2023 16:01:27 +0100 Subject: [PATCH 1/2] fix: name output when running post_write hooks --- alembic/script/write_hooks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/alembic/script/write_hooks.py b/alembic/script/write_hooks.py index 0e9ec40a..781b3fc6 100644 --- a/alembic/script/write_hooks.py +++ b/alembic/script/write_hooks.py @@ -85,7 +85,9 @@ def _run_hooks(path: str, hook_config: Mapping[str, str]) -> None: "Key %s.type is required for post write hook %r" % (name, name) ) from ke else: - with util.status("Running post write hook {name!r}", newline=True): + with util.status( + "Running post write hook %r" % name, newline=True + ): _invoke(type_, path, opts) From 19d17f5d061319bbf142b45a593081da5fc1dda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20D=C3=A9fosse?= Date: Sat, 17 Jun 2023 16:43:08 +0100 Subject: [PATCH 2/2] style: use f-strings instead of % interpolation --- alembic/script/write_hooks.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/alembic/script/write_hooks.py b/alembic/script/write_hooks.py index 781b3fc6..5f53dc20 100644 --- a/alembic/script/write_hooks.py +++ b/alembic/script/write_hooks.py @@ -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) @@ -82,11 +82,11 @@ 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 %r" % name, newline=True + f"Running post write hook {name!r}", newline=True ): _invoke(type_, path, opts) @@ -120,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: @@ -143,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,