]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commit
fix: Correct the AutogenContext.metadata typing to include Sequence[MetaData].
authorDanCardin <ddcardin@gmail.com>
Wed, 6 Nov 2024 17:10:12 +0000 (12:10 -0500)
committersqla-tester <sqla-tester@sqlalchemy.org>
Wed, 6 Nov 2024 17:10:12 +0000 (12:10 -0500)
commit191c14a544bffcae43a516389ec7634afa524103
treea27d19801290546a04fa0989a0a1a5d41027c8c6
parentb6b44c1e90c96b55939b28d73f427eff7b9cb620
fix: Correct the AutogenContext.metadata typing to include Sequence[MetaData].

### Description
The type annotation for AutogenContext.metadata is currently `Optional[MetaData]`, but `target_metadata` is `Union[MetaData, Sequence[MetaData], None]`. Seems like setting `target_metadata` to `[]` directly translates into the list that `AutogenContext` receives, and that the code is already coercing the potential single/sequence to always be a list.

My alembic plugin wasn't aware that this **could** be a list, and as such wasn't handling the possibility properly.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [x] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #1547
Pull-request: https://github.com/sqlalchemy/alembic/pull/1547
Pull-request-sha: 1bdfa18739e3d156f267953c71267feeded9543b

Change-Id: Ib3114b19c10983114b834676ada69d7475e82fe5
alembic/autogenerate/api.py