diff options
author | CaselIT <cfederico87@gmail.com> | 2021-04-18 15:44:50 +0200 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-08-11 15:04:56 -0400 |
commit | 6aad68605f510e8b51f42efa812e02b3831d6e33 (patch) | |
tree | cc0e98b8ad8245add8692d8e4910faf57abf7ae3 /docs | |
parent | 3bf6a326c0a11e4f05c94008709d6b0b8e9e051a (diff) | |
download | alembic-6aad68605f510e8b51f42efa812e02b3831d6e33.tar.gz |
Add pep-484 type annotations
pep-484 type annotations have been added throughout the library. This
should be helpful in providing Mypy and IDE support, however there is not
full support for Alembic's dynamically modified "op" namespace as of yet; a
future release will likely modify the approach used for importing this
namespace to be better compatible with pep-484 capabilities.
Type originally created using MonkeyType
Add types extracted with the MonkeyType https://github.com/instagram/MonkeyType
library by running the unit tests using ``monkeytype run -m pytest tests``, then
``monkeytype apply <module>`` (see below for further details).
USed MonkeyType version 20.5 on Python 3.8, since newer version have issues
After applying the types, the new imports are placed in a ``TYPE_CHECKING`` guard
and all type definition of non base types are deferred by using the string notation.
NOTE: since to apply the types MonkeType need to import the module, also the test
ones, the patch below mocks the setup done by pytest so that the tests could be
correctly imported
diff --git a/alembic/testing/__init__.py b/alembic/testing/__init__.py
index bdd1746..b1090c7 100644
Change-Id: Iff93628f4b43c740848871ce077a118db5e75d41
--- a/alembic/testing/__init__.py
+++ b/alembic/testing/__init__.py
@@ -9,6 +9,12 @@ from sqlalchemy.testing.config import combinations
from sqlalchemy.testing.config import fixture
from sqlalchemy.testing.config import requirements as requires
+from sqlalchemy.testing.plugin.pytestplugin import PytestFixtureFunctions
+from sqlalchemy.testing.plugin.plugin_base import _setup_requirements
+
+config._fixture_functions = PytestFixtureFunctions()
+_setup_requirements("tests.requirements:DefaultRequirements")
+
from alembic import util
from .assertions import assert_raises
from .assertions import assert_raises_message
Currently I'm using this branch of the sqlalchemy stubs:
https://github.com/sqlalchemy/sqlalchemy2-stubs/tree/alembic_updates
Change-Id: I8fd0700aab1913f395302626b8b84fea60334abd
Diffstat (limited to 'docs')
-rw-r--r-- | docs/build/unreleased/py3_typing.rst | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/build/unreleased/py3_typing.rst b/docs/build/unreleased/py3_typing.rst new file mode 100644 index 0000000..7f8aa6c --- /dev/null +++ b/docs/build/unreleased/py3_typing.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: feature, general + + pep-484 type annotations have been added throughout the library. This + should be helpful in providing Mypy and IDE support, however there is not + full support for Alembic's dynamically modified "op" namespace as of yet; a + future release will likely modify the approach used for importing this + namespace to be better compatible with pep-484 capabilities.
\ No newline at end of file |