From 51b307247de12f77b2e482b7bd90a244394566b9 Mon Sep 17 00:00:00 2001 From: Mike Waites Date: Sun, 30 Dec 2018 16:09:27 +0000 Subject: Provide revision post-write hooks Added "post write hooks" to revision generation. The primary rationale is to provide for code formatting tools to automatically format new revisions, however any arbitrary script or Python function may be invoked as a hook. The hooks are enabled by providing a ``[post_write_hooks]`` section in the alembic.ini file. The provided hook is a command-line runner which includes configuration examples for running Black or autopep8 on newly generated revision scripts. The documentation also illustrates a custom hook that converts Python source spaces to tabs, as requested in #577. Co-authored-by: Mike Bayer Fixes: #307 Fixes: #577 Change-Id: I9d2092d20ec23f62ed3b33d979c16b979a450b48 --- alembic/templates/pylons/alembic.ini.mako | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'alembic/templates/pylons') diff --git a/alembic/templates/pylons/alembic.ini.mako b/alembic/templates/pylons/alembic.ini.mako index 6f6511b..70fead0 100644 --- a/alembic/templates/pylons/alembic.ini.mako +++ b/alembic/templates/pylons/alembic.ini.mako @@ -35,6 +35,17 @@ script_location = ${script_location} # are written from script.py.mako # output_encoding = utf-8 +[post_write_hooks] +# post_write_hooks defines scripts or Python functions that are run +# on newly generated revision scripts. See the documentation for further +# detail and examples + +# format using "black" - use the console_scripts runner, against the "black" entrypoint +# hooks=black +# black.type=console_scripts +# black.entrypoint=black +# black.options=-l 79 + pylons_config_file = ./development.ini # that's it ! \ No newline at end of file -- cgit v1.2.1