summaryrefslogtreecommitdiff
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* Define type for generic classesFederico Caselli2023-05-161-0/+6
| | | | | | | | Fixed typing use of :class:`~sqlalchemy.schema.Column` and other generic SQLAlchemy classes. Fixes: #1246 Change-Id: I5ee80395d626894a52e3395c9986213289576355
* Added ``op.run_async``.Federico Caselli2023-05-121-1/+4
| | | | | | | | | | | | | | Added :meth:`.Operations.run_async` to the operation module to allow running async functions in the ``upgrade`` or ``downgrade`` migration function when running alembic using an async dialect. This function will receive as first argument an class:`~sqlalchemy.ext.asyncio.AsyncConnection` sharing the transaction used in the migration context. also restore the .execute() method to BatchOperations Fixes: #1231 Change-Id: I3c3237d570be3c9bd9834e4c61bb3231bfb82765
* Add Operations and BatchOperations stub methodsCaselIT2023-05-041-86/+217
| | | | | | | | | | | | | Updated stub generator script to also add stubs method definitions for the :class:`.Operations` class and the :class:`.BatchOperations` class obtained from :meth:`.Operations.batch_alter_table`. Repaired the return signatures for :class:`.Operations` that mostly return ``None``, and were erroneously referring to ``Optional[Table]`` in many cases. Fixes: #1093 Change-Id: I98d38dd5a1e719b4dbbc1003746ec28f26c27808
* Improve typing.Federico Caselli2023-04-131-1/+2
| | | | | | | | Correctly pass previously ignored arguments ``insert_before`` and ``insert_after`` in ``batch_alter_column`` Fixes: #1221 Change-Id: I79c9144f3e521fca00a0c32462ae2a69f9f7a032
* tooling: write_pyi.py: filter usage of raw-strings (rstrings)James Addison2023-04-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | ### Description While reading the diff between [`rel_1_10_2...rel_1_10_3`](https://github.com/sqlalchemy/alembic/compare/rel_1_10_2...rel_1_10_3), the introduction of r-strings drew my attention, and that resulted in some [discussion on the relevant commit](https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33). This changeset filters the production of r-strings during stub-generation to cases where docstrings contain escape (backslash, `\`) characters. I'll admit that I didn't realize until today that these stubs are primarily for typechecking. Since that's the case, I have doubts about whether the change is worthwhile (consistency and simplicity -- using r-strings for all docstrings in the stubs -- even if it's redundant, seems fine to me). ### Checklist This pull request is: - [x] A documentation / typographical error fix - [x] A short code fix - Relates to discussion at https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33 Closes: #1218 Pull-request: https://github.com/sqlalchemy/alembic/pull/1218 Pull-request-sha: 352ab8829525435f78838687e12156a3fa3a3d86 Closes: #1219 Pull-request: https://github.com/sqlalchemy/alembic/pull/1219 Change-Id: I2808a592681dabc093d538f589e673fcc5e05822
* Fix type annotation for `url`Viicos2023-04-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Provide a general summary of your proposed changes in the Title field above --> Left the `pyi` generated file untouched. ### Description <!-- Describe your changes in detail --> ### 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: #1209 Pull-request: https://github.com/sqlalchemy/alembic/pull/1209 Pull-request-sha: d15cb6e28d5bb934d139ced87e713a9d77505346 Change-Id: I8548806a693b150f1417a102e6498119524008a0
* Fix unknown types reported by pyrightCaselIT2023-03-101-1/+1
| | | | | | | | | | Fixed various typing issues observed with pyright, including issues involving the combination of :class:`.Function` and :meth:`.MigrationContext.begin_transaction`. Fixes: #1191 Fixes: #1201 Change-Id: I9856a8f59c22130c8bbcbed3e19cf2e8a8bf0608
* Update docstring to suggest raw string (#1186)Tim Penhey2023-02-231-0/+3
| | | | | | | | | | | | | | * Update docstring to suggest raw string When escaping the `:` for `op.execute` if a normal string is used, you need to escape the backslash, eg. `'\\:colon_value'` or using a raw string. For the docs I feel it is nicer to show the raw string. * Update stub documentation Change-Id: Ia605c6c036fe82cebff9b427333404f1c59ea74d --------- Co-authored-by: CaselIT <cfederico87@gmail.com>
* add overload stubs for proxied classesVincent Fazio2023-01-031-10/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description Closes #1146 Closes #1147 <!-- Describe your changes in detail --> Overloaded functions would not have type stubs generated by the stub generator for proxied classes. Now they will. ### 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: - [ ] A documentation / typographical error fix - Good to go, no issue or tests are needed - [x] 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. Closes: #1148 Pull-request: https://github.com/sqlalchemy/alembic/pull/1148 Pull-request-sha: ed3c28cc78e57314b7a4e533d77108efc6751949 Change-Id: I7c0ee9d333015174ee6ab754909748f745af2ff9
* add typing parametersMike Bayer2022-11-151-5/+3
| | | | | | | | | | Fixed typing issue where :paramref:`.revision.process_revision_directives` was not fully typed; additionally ensured all ``Callable`` and ``Dict`` arguments to :meth:`.EnvironmentContext.configure` include parameters in the typing declaration. Change-Id: I3ac389992f357359439be5659af33525fc290f96 Fixes: #1110
* Improve typingCaselIT2022-09-121-1/+4
| | | | Change-Id: I9fc86c4a92e1b76d19c9e891ff08ce8a46ad4e35
* Annotate batch_alter_tableCaselIT2022-06-041-20/+18
| | | | | | | | | Fixes: #975 Closes: #1032 Pull-request: https://github.com/sqlalchemy/alembic/pull/1032 Pull-request-sha: a111d4f446e861bd01a3cea7ebd1c18a2446601a Change-Id: Idb8e1c8b6577204a64cde195f094830cdbba68ce
* Various typing related updatesCaselIT2022-04-231-8/+48
| | | | Change-Id: I778b63b1c438f31964d841576f0dd54ae1a5fadc
* Added missing attributes from context stubs.CaselIT2021-09-141-3/+2
| | | | | Fixes: #900 Change-Id: I2e21b6f363bf6405bd472c9aca04fbbc3c9cc384
* Adds exception when trying to run write_pyi.py with Python < 3.9TilmanK2021-09-141-3/+10
| | | | | | | | | | | | | | | | | ### Description write_pyi.py now raises an exception when someone tries to run the script with Python version 3.8 or smaller. This also fixes: - When using absolute Paths, i.e. on Windows, they are now converted to relative paths to avoid useless changes in the doc strings of the pyi files - Corrected destination_path argument type when calling `generate_pyi_for_proxy` in `run_file` - A comment typo Fixes: #915 Closes: #919 Pull-request: https://github.com/sqlalchemy/alembic/pull/919 Pull-request-sha: e885d27ac5509858c8cb2927310f6195fc1d6004 Change-Id: Ia33d32b2828e71185186afc49848ce89d48a8323
* restore default values for keyword arguments in stubsMike Bayer2021-08-301-3/+1
| | | | | | | | Fixed issue in generated .pyi files where default values for ``Optional`` arguments were missing, thereby causing mypy to consider them as required. Change-Id: I08c4cd7bd04c6763fdc9c5b42abbdcca8fd90e0e Fixes: #895
* decouple pyproject.toml from the test suiteMike Bayer2021-08-261-2/+4
| | | | | | | | | | | | | tools/write_pyi.py is run as part of the test suite, which has to run from a source distribution, which does not have pyproject.toml right now due to issues reported w/ pip. these pip issues are probably resolved now however we have not gone back to including pyproject.toml at the moment. so we therefore have to hardcode the single "-l79" black config option in write_pyi.py. Change-Id: I877f69eb2322f6cbb39ed4c6d4a9adf598703223
* append the path to write_pyi script.CaselIT2021-08-241-5/+8
| | | | | | This allows running without having alembic installed Change-Id: I1cc4f108916233e7b149485a42cae759e7e3b577
* avoid importing ForwardRef that's py3.9+ onlyCaselIT2021-08-231-1/+2
| | | | Change-Id: I76654f10e208d618e21ab0c884cb0abede4d6177
* generate .pyi files for proxied classesMike Bayer2021-08-221-0/+195
Stub .pyi files have been added for the "dynamically" generated Alembic modules ``alembic.op`` and ``alembic.context``, which include complete function signatures and docstrings, so that the functions in these namespaces will have both IDE support (vscode, pycharm, etc) as well as support for typing tools like Mypy. The files themselves are statically generated from their source functions within the source tree. Still not available is sphinx autodoc from the .pyi file. so we might want to further modify this to write into the .py directly. if we do *that*, we could almost get rid of ModuleClsProxy and just generate proxying methods fully in op.py. however, this won't work for the "extending ops" use case. Change-Id: I3f084040de25ed3f8e92a4e9d0bb83d69b78eac6