Entry point for DefaultImpl subclasses? (or, just use plugins?)
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
調査の方向性
Review Alembic's existing plugin ecosystem and the linked pull request #1875, then compare that approach with the proposed alembic.implementations entry point. Done means the project has a clear decision on registration order and whether the existing plugin pattern should be documented or a new entry point supported.
索引モデルが issue の本文から書いたものです。
説明
Discussed in https://github.com/sqlalchemy/alembic/discussions/1872
Originally posted by dwreeves September 30, 2026
Hello,
I could not find any discussion on this elsewhere.
I'm wondering if it would make sense for Alembic to support entry-points for Defaultmpl subclasses.
Right now, it looks like the pattern some third-party providers use (e.g. sqlalchemy-redshift) is to load the impl as a side-effect of importing the SqlAlchemy dialect module entry-point.
There are two advantages of an entry-point. The first would be not needing to import Alembic or register anything during the normal runtime of the application. Not usually a big deal to have Alembic in the sys modules, but could be nice-to-have for custom dialects.
The second is a little more subtle, but the entry-point invocation could control the order of registration of dialects, so that the env.py's dialect is guaranteed to resolve last.
The second is actually relevant to a PR I have open for snowflake-sqlalchemy: right now there is no guarantee of whether the library provided SnowflakeImpl will resolve before or after a user's custom implementation; it's totally dependent on the env.py's imports. If entry-points are respected however, then Alembic can always resolve entry-points before env.py runs, guaranteeing user-generated DefaultImpls are resolved last. https://github.com/snowflakedb/snowflake-sqlalchemy/issues/758
So e.g. I have a SQLAlchemy driver for MyCoolSqlDatabase, I could structure like this:
pyproject.toml
src/
mycoolsqldatabase_sqlalchemy/
__init__.py
dialect.py
alembic.py
# pyproject.toml
[project.entry-points."sqlalchemy.dialects"]
mycoolsqldatabase = "mycoolsqldatabase_sqlalchemy:dialect"
[project.entry-points."alembic.implementations"]
mycoolsqldatabase = "mycoolsqldatabase_sqlalchemy:alembic" # alternatively mycoolsqldatabase_sqlalchemy.alembic:MyCoolSqlDatabaseImpl
An argument against this--
I am aware that Alembic uses entry-points for plugins.
Perhaps the pattern you might suggest is to create a plugin with an empty setup() that registers the Alembic impl as a side-effect? E.g.
# plugin.py
from alembic.ddl.impl import DefaultImpl
class MyCoolSqlDatabaseImpl(DefaultImpl):
__dialect__ = "my_cool_sql_database"
def setup(plugin):
pass
If so, it may make sense to show that as an example in the documentation. If that is guaranteed to resolve before env.py, then that could also work as a path for the aforementioned PR.
I think the upside to using the existing plugin ecosystem is that it reduces the API surface on Alembic's end, but the downside is this is very cheeky and not intuitive, especially without a documented example.
Lastly, thanks for the awesome ecosystem, zzzeeek.
- 主要言語
- Python
- スター
- 4.5k
- フォーク
- 391
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sqlalchemy/alembic のほかの issue
-
on_version_apply is typed as a positional callable, but alembic calls it with keyword arguments再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sqlalchemy/alembic#1883 · コメント 1 件 ·
-
Revision message is rendered unescaped into the migration docstring; triple quotes and backslashes break the generated script再び着手できるかも @ApparentlyTejas が 21 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug command interface
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
sqlalchemy/alembic#1879 · コメント 3 件 ·
-
bug pep 484
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
sqlalchemy/alembic#1341 · コメント 2 件 ·
-
autogenerate - detection bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
sqlalchemy/alembic#1121 · コメント 3 件 ·
-
Identity and Computed comparison skipped when compare_server_default is not set, as of 1.18.0再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンautogenerate - defaults bug regression
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
sqlalchemy/alembic#1877 · コメント 1 件 ·
sqlalchemy/alembic の issue をすべて見る
似ている issue
-
SslLibrary crashes with unhandled OSError: port/proto not found on non-standard SSL ports対応中かも @himanchalkaushale が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
OWASP/Nettacker#1884 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
A-connection-core C-enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
aws-samples/sample-per-model-bedrock#869 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
fzn0x/watchtower#17 ·