-
Notifications
You must be signed in to change notification settings - Fork 968
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
configuration story needs to improve
#10053
Comments
Hey, thanks for opening the issue. For the record, I'm not entirely comfortable with how adversarial the conversation went on the alembic discussion you linked. Given an upstream tool provider has already implemented everything we need to get it done easily on our side, I don't think it's fair to request that our own usecase would become the new default for everyone. The Python world is large, the practices are equally diverse, and when a project like Alembic has made a choice to provide a hook and not "just" lint by default, it's rarely an oversight. Especially when they explained the reasoning behind this choice, I'm not sure there was a need to continue insisting. I can see how the Alembic people might not have gotten a good experience of this interaction. PyPI is an important project among the community, and we ought to project the best of ourselves to other people when interacting with them in the name of this project. Keep in mind that we're (mostly) all volunteers here with limited time to tackle interesting problems. With that said, I believe alembic configuration is dynamic, not static (thus why we can't find a .ini file). |
I believe this would look something like: hooks = {
"black": {"options": "..."},
"isort": {"options": "..."},
}
alembic_cfg.set_section_option(section="post_write_hooks", name="hooks", value=",".join(hooks))
for key, config in hooks.items():
config["type"] = "console_scripts"
config["entrypoint"] = key
for name, value in config.items():
alembic_cfg.set_section_option(section="post_write_hooks", name=f"{key}.{name}", value=value) or alternatively: alembic_cfg.set_section_option(section="post_write_hooks", name="hooks", value="black,isort")
alembic_cfg.set_section_option(section="post_write_hooks", name="black.type", value="console_scripts")
alembic_cfg.set_section_option(section="post_write_hooks", name="black.entrypoint", value="black")
alembic_cfg.set_section_option(section="post_write_hooks", name="black.options", value="...")
alembic_cfg.set_section_option(section="post_write_hooks", name="isort.type", value="console_scripts")
alembic_cfg.set_section_option(section="post_write_hooks", name="isort.entrypoint", value="isort")
alembic_cfg.set_section_option(section="post_write_hooks", name="isort.options", value="...") |
I didn't like the way the report went myself, but I hope we cleared misunderstandings in the process.
Is it possible to point it to the |
I don't understand your suggestion. I'd say either we need to have all the configuration in an ini file, or none. My suggestion was if we went towards none. I don't know what will need to change for us to go to "all". |
I'd actually prefer all Alembic config to be in |
Well, you'll have to figure out how to link to the database url, which is a project setting, controllable by an environment variable. |
Alembic allows to merge configs, but it doesn't report if it fails to find the config file - sqlalchemy/alembic#931 So far I couldn't make it work. |
The `url` setting was unused - it should be `sqlalchemy.url`, and the DB is set up in `env.py`.
I am trying to use |
After a migration file is generated, run `black` and `isort` to conform to our linter rules. Closes pypi#10053 Closes pypi#10146 Signed-off-by: Mike Fiedler <[email protected]>
After a migration file is generated, run `black` and `isort` to conform to our linter rules. Closes #10053 Closes #10146 Signed-off-by: Mike Fiedler <[email protected]> Signed-off-by: Mike Fiedler <[email protected]>
What's the problem this feature will solve?
Fixing linting errors after
alembic
is easy, but a time consuming distractions. Whilealembic
doesn't produce linter friendly output by default, it allows to run write hooks. https://alembic.sqlalchemy.org/en/latest/autogenerate.html?highlight=black#applying-post-processing-and-python-code-formatters-to-generated-revisionsDescribe the solution you'd like
I would like autogenerated migrations to be
black
andisort
valid.Additional context
I could not find where Pyramid stores configuration for
alembic
, so I can't solve this issue right now.Long story sqlalchemy/alembic#925
The text was updated successfully, but these errors were encountered: