Entry point for DefaultImpl subclasses? (or, just use plugins?)
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 4.5k
- Fork
- 391
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sqlalchemy/alembic
-
on_version_apply is typed as a positional callable, but alembic calls it with keyword argumentsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sqlalchemy/alembic#1883 · 1 bình luận ·
-
Revision message is rendered unescaped into the migration docstring; triple quotes and backslashes break the generated scriptCó thể làm lại được @ApparentlyTejas đã nhận 21 ngày trước và không có pull request nào đang mở. Đang mởbug command interface
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
sqlalchemy/alembic#1879 · 3 bình luận ·
-
bug pep 484
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
sqlalchemy/alembic#1341 · 2 bình luận ·
-
autogenerate - detection bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
sqlalchemy/alembic#1121 · 3 bình luận ·
-
Identity and Computed comparison skipped when compare_server_default is not set, as of 1.18.0Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởautogenerate - defaults bug regression
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
sqlalchemy/alembic#1877 · 1 bình luận ·
Tất cả issue của sqlalchemy/alembic
Issue tương tự
-
SslLibrary crashes with unhandled OSError: port/proto not found on non-standard SSL portsCó thể đã có người làm @himanchalkaushale đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OWASP/Nettacker#1884 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A-connection-core C-enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
aws-samples/sample-per-model-bedrock#869 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Spec: say that included_antigen_sources gates LENS labels; do not merge it into antigen kindsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
fzn0x/watchtower#17 ·