Skip to content

Support for non-Python post-write hooks #1275

@lanzz

Description

@lanzz

Describe the bug
I'm using Ruff to lint and reformat my code, and I'm trying to get it working as a post-write hook in Alembic, but Ruff is actually written in Rust and is installed as a compiled binary, so it isn't included in importlib metadata as a console-scripts entrypoint, and Alembic throws an "Could not find entrypoint console_scripts.ruff" error.

Expected behavior
There should be an out of the box write hook runner that can execute arbitrary binaries, and not just the console-scripts runner that only supports Python modules' entrypoints.

To Reproduce
Install Ruff:

$ pip install ruff

Confirm that the ruff binary is in path and can be executed:

$ ruff --version
ruff 0.0.278

In alembic.ini:

...
[post_write_hooks]
hooks = ruff
ruff.type = console_scripts
ruff.entrypoint = ruff
ruff.options = --fix REVISION_SCRIPT_FILENAME
...

Error

  Generating /srv/app/alembic/versions/2023-07-15_2341_ecc9e22f7cf5_.py ...  done
  Running post write hook {name!r} ...
  FAILED
  FAILED: Could not find entrypoint console_scripts.ruff

Versions.

  • OS: Debian 12.0
  • Python: 3.11.4
  • Alembic: 1.11.1
  • SQLAlchemy: 2.0.19
  • Database: irrelevant
  • DBAPI: irrelevant

Additional context

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    autogenerate - renderinguse casenot quite a feature and not quite a bug, something we just didn't think of

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions