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

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

Closed
FeeeeK opened this issue Aug 22, 2023 · 2 comments
Labels
bug Something isn't working command interface
Milestone

Comments

@FeeeeK
Copy link

FeeeeK commented Aug 22, 2023

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!

@FeeeeK FeeeeK added the requires triage New issue that requires categorization label Aug 22, 2023
@sqla-tester
Copy link
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

@zzzeek zzzeek added bug Something isn't working command interface and removed requires triage New issue that requires categorization labels Aug 22, 2023
@zzzeek
Copy link
Member

zzzeek commented Aug 22, 2023

thanks for reporting

@CaselIT CaselIT added this to the 1.12 milestone Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working command interface
Projects
None yet
Development

No branches or pull requests

4 participants