]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Fixed CLI output when running post_write hooks
authorMathieu Défosse <mathieu.defosse@hey.com>
Sat, 17 Jun 2023 17:46:08 +0000 (13:46 -0400)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 20 Jun 2023 17:48:35 +0000 (19:48 +0200)
Fixes: #1261
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
Just fixed badly written Python string interpolation. Used the `%` operator just like the lines above.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #1262
Pull-request: https://github.com/sqlalchemy/alembic/pull/1262
Pull-request-sha: 19d17f5d061319bbf142b45a593081da5fc1dda8

Change-Id: I89ef873935d7206a61f78a09139cd5ab192a2275

alembic/script/write_hooks.py
docs/build/unreleased/1261.rst [new file with mode: 0644]

index 0e9ec40a0a2e70069c739b4f9f928dcc762338ed..5f53dc2072e0116446a582e06222170d136fa133 100644 (file)
@@ -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,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)
 
 
@@ -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:
@@ -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,
diff --git a/docs/build/unreleased/1261.rst b/docs/build/unreleased/1261.rst
new file mode 100644 (file)
index 0000000..b8e483c
--- /dev/null
@@ -0,0 +1,6 @@
+.. change::
+    :tags: bug
+    :tickets: 1261
+
+    Fixed format string logged when running a post write hook
+    Pull request curtesy of Mathieu Défosse.