Skip to content

alembic merge ignores revision_environment and cannot find the hooks defined in env.py #1299

Closed

Description

@axd1x8a

Describe the bug
As title says, alembic merge ignores revision_environment and cannot find the hooks defined in env.py.

Expected behavior
Custom hooks work the way they do when generating revisions

To Reproduce

# alembic.ini
revision_environment = true
hooks = ruff
ruff.type = ruff
ruff.options = --select I --select F401 --fix
# env.py
from alembic.script import write_hooks

@write_hooks.register("ruff")
def run_ruff(filename, options):
    ruff = os.path.join(sysconfig.get_path("scripts"), "ruff")
    os.system(f"{ruff} {options['options']} {filename}")  # noqa: S605

Error

Running post write hook 'ruff' ...
  FAILED
FAILED: No formatter with name 'ruff' registered.

Versions.

  • Python: 3.11.1
  • Alembic: 1.11.3

Additional context
For the ruff example, this may become useless after #1276, but it is still needed for the rest of the custom hooks .

Have a nice day!
Thanks, you too!

Activity

  1. sqla-tester commented on Aug 22, 2023

    @sqla-tester
    Collaborator

    Mike Bayer has proposed a fix for this issue in the main branch:

    implement revision_environment for merge https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4817

  2. added
    bugSomething isn't working
    and removed
    requires triageNew issue that requires categorization
    on Aug 22, 2023
  3. zzzeek commented on Aug 22, 2023

    @zzzeek
    Member

    thanks for reporting

  4. added this to the 1.12 milestone on Aug 31, 2023
  5. added a commit that references this issue on Sep 27, 2024
    f4d439e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions