Generate linter friendly output by default #925
Replies: 3 comments 33 replies
-
Hi, you are free to modify the template file however you want. |
Beta Was this translation helpful? Give feedback.
-
hi there - Alembic supports the feature you request fully. Please see: https://alembic.sqlalchemy.org/en/latest/autogenerate.html?highlight=black#applying-post-processing-and-python-code-formatters-to-generated-revisions which will illustrate how to plug in the "black" code formatter, or any other formatters you'd like. |
Beta Was this translation helpful? Give feedback.
-
there are many import ordering styles besides isort. We use zimports which will make use of any of the ordering styles used by flake8-import-order, and we use the "google" style. The imports as they are in the template right now are already compliant with "google" and changing them as proposed makes them non-compliant. these templates are generated into the user-project directory, which is not the "alembic" project; therefore both the "sqlalchemy" and "alembic" imports are third party imports, and should be together and alphabetically ordered. as stated previously, there is no fixed import order in Python so people need to use the post_write_hooks to install the formatting they prefer. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Generated migrations are not linter friendly.
black
fails, because migrations use single quotes.isort
because imports are not properly ordered.Perhaps there are more issues, but at least these two could already make it better.
Expected behavior
Generated migration to be
black
andisort
compatible.Beta Was this translation helpful? Give feedback.
All reactions