diff options
author | Vincent Fazio <vfazio@gmail.com> | 2023-01-03 12:39:13 -0500 |
---|---|---|
committer | sqla-tester <sqla-tester@sqlalchemy.org> | 2023-01-03 12:39:13 -0500 |
commit | 40df5ecb410660fdf96a750d626d4f2f5b2d98ea (patch) | |
tree | 3d35c5b8f558da6885de148c2a4e19dd6cfe173d /alembic | |
parent | 7cda8187d63c0c64c0a08b8763c2d41c0f970032 (diff) | |
download | alembic-40df5ecb410660fdf96a750d626d4f2f5b2d98ea.tar.gz |
add overload stubs for proxied classes
<!-- 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
Diffstat (limited to 'alembic')
-rw-r--r-- | alembic/context.pyi | 9 | ||||
-rw-r--r-- | alembic/runtime/environment.py | 14 | ||||
-rw-r--r-- | alembic/util/compat.py | 1 |
3 files changed, 17 insertions, 7 deletions
diff --git a/alembic/context.pyi b/alembic/context.pyi index 9871fad..86345c4 100644 --- a/alembic/context.pyi +++ b/alembic/context.pyi @@ -7,7 +7,9 @@ from typing import Callable from typing import ContextManager from typing import Dict from typing import List +from typing import Literal from typing import Optional +from typing import overload from typing import TextIO from typing import Tuple from typing import TYPE_CHECKING @@ -644,8 +646,13 @@ def get_tag_argument() -> Optional[str]: """ +@overload +def get_x_argument(as_dictionary: Literal[False]) -> List[str]: ... +@overload +def get_x_argument(as_dictionary: Literal[True]) -> Dict[str, str]: ... +@overload def get_x_argument( - as_dictionary: bool = False, + as_dictionary: bool = ..., ) -> Union[List[str], Dict[str, str]]: """Return the value(s) passed for the ``-x`` argument, if any. diff --git a/alembic/runtime/environment.py b/alembic/runtime/environment.py index 44dcd72..a441d1f 100644 --- a/alembic/runtime/environment.py +++ b/alembic/runtime/environment.py @@ -269,15 +269,17 @@ class EnvironmentContext(util.ModuleClsProxy): return self.context_opts.get("tag", None) @overload - def get_x_argument( # type:ignore[misc] - self, as_dictionary: Literal[False] = ... - ) -> List[str]: + def get_x_argument(self, as_dictionary: Literal[False]) -> List[str]: ... @overload - def get_x_argument( # type:ignore[misc] - self, as_dictionary: Literal[True] = ... - ) -> Dict[str, str]: + def get_x_argument(self, as_dictionary: Literal[True]) -> Dict[str, str]: + ... + + @overload + def get_x_argument( + self, as_dictionary: bool = ... + ) -> Union[List[str], Dict[str, str]]: ... def get_x_argument( diff --git a/alembic/util/compat.py b/alembic/util/compat.py index 289aaa2..2fe4957 100644 --- a/alembic/util/compat.py +++ b/alembic/util/compat.py @@ -10,6 +10,7 @@ from sqlalchemy.util.compat import inspect_formatargspec # noqa is_posix = os.name == "posix" +py311 = sys.version_info >= (3, 11) py39 = sys.version_info >= (3, 9) py38 = sys.version_info >= (3, 8) |