Repository navigation
Conversation
The callback is invoked with keyword arguments only (ctx, step, heads, run_args), matching the documented contract. Fixes: sqlalchemy#1883
|
Hi, and thanks for the pull request! This project accepts pull requests only for issues that a maintainer has already marked with the open for pull requests label. That way we can settle on an approach before anyone spends time writing code. This pull request references issue #1883, which hasn't been marked open for pull requests, so the change isn't authorized yet and I'm closing it automatically. Once a maintainer adds the label to #1883, reopen this pull request and it will stay open. If #1883 needs more detail before that can happen, a complete runnable example is usually the missing piece, and adding one to the issue is the fastest way to get there. This is automatic and procedural. It isn't a judgment on your change, and nothing you've written here is lost. Thanks for your interest in the project! |
Fixes: #1883
Summary
EnvironmentContext.configure(on_version_apply=...)is documented and invoked as a keyword-only callback (callback(ctx=..., step=..., heads=..., run_args=...)inalembic/runtime/migration.py), butOnVersionApplyFnwas typed as a positionalCallable. Type checkers therefore rejected valid keyword-only callbacks and accepted callbacks whose parameter names would fail at runtime.Changes
alembic/runtime/environment.py:OnVersionApplyFnis now atyping.Protocolwith keyword-only parametersctx,step,heads,run_args, matching the documented contract.alembic/context.pyi: regenerated withtools/write_pyi.py(Python 3.14).tools/write_pyi.py: addedalembic.runtime.environment.toTRIM_MODULEso the stub renders the bare name, consistent with the other module prefixes.docs/build/unreleased/1883.rst: changelog entry.Validation
tests/test_stubs.pypasses under Python 3.14 (stub regeneration is byte-identical).tests/test_script_consumption.py+tests/test_environment.py: 92 passed (sqlite), including the existingCallbackEnvironmentTestthat asserts the keyword-argument invocation.mypy ./alembic/ --exclude alembic/templates: no new errors (the 6 pre-existingnoxfile.pyuntyped-decorator notes are identical on base).This contribution was prepared with AI assistance (Instinct agent on behalf of @anish-yen), including local test and type-check validation.