-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Combine microsoft/python-type-stubs/sqlalchemy #9597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment has been minimized.
This comment has been minimized.
Avasam
commented
Jan 28, 2023
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…hemy-from-python-type-stubs
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@hauntsaninja I have a mypy_primer question for you. What's up with these diff lines --> And does it mean anything to us or is it related to: https://github.com/hauntsaninja/mypy_primer/blob/master/mypy_primer.py#L521 Edit: no longer an issue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…m/Avasam/typeshed into sqlalchemy-from-python-type-stubs
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…m/Avasam/typeshed into sqlalchemy-from-python-type-stubs
This comment has been minimized.
This comment has been minimized.
I'm not getting this pytype error locally with WSL. |
This comment has been minimized.
This comment has been minimized.
…hemy-from-python-type-stubs
This comment has been minimized.
This comment has been minimized.
…hemy-from-python-type-stubs
Diff from mypy_primer, showing the effect of this PR on open source code: optuna (https://github.com/optuna/optuna)
- optuna/storages/_rdb/models.py:64: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:72: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:119: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:151: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:187: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:213: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:245: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:290: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:322: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:377: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:451: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:524: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
+ optuna/storages/_rdb/models.py:571: error: Incompatible return value type (got "Optional[VersionInfoModel]", expected "VersionInfoModel") [return-value]
- optuna/storages/_rdb/models.py:556: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/models.py:569: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/storage.py:757: error: Call to untyped function "one_or_none" in typed context [no-untyped-call]
- optuna/storages/_rdb/storage.py:807: error: Incompatible types in assignment (expression has type "Set[Any]", variable has type "List[Tuple[Any]]") [assignment]
+ optuna/storages/_rdb/storage.py:807: error: Incompatible types in assignment (expression has type "Set[Any]", variable has type "List[Any]") [assignment]
- optuna/storages/_rdb/storage.py:1143: error: Incompatible return value type (got "ColumnOperators[Any]", expected "bool") [return-value]
+ optuna/storages/_rdb/storage.py:1143: error: Incompatible return value type (got "Union[BinaryExpression, bool]", expected "bool") [return-value]
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/server/utilities/database.py:240: error: Incompatible types in assignment (expression has type "Timestamp", base class "ColumnElement" defined the type as "Callable[[ColumnElement[Any]], Optional[TypeEngine]]") [assignment]
+ src/prefect/server/utilities/database.py:277: error: Incompatible types in assignment (expression has type "Timestamp", base class "ColumnElement" defined the type as "Callable[[ColumnElement[Any]], Optional[TypeEngine]]") [assignment]
+ src/prefect/server/utilities/database.py:330: error: Incompatible types in assignment (expression has type "Interval", base class "ColumnElement" defined the type as "Callable[[ColumnElement[Any]], Optional[TypeEngine]]") [assignment]
+ src/prefect/server/utilities/database.py:382: error: Incompatible types in assignment (expression has type "Interval", base class "ColumnElement" defined the type as "Callable[[ColumnElement[Any]], Optional[TypeEngine]]") [assignment]
+ src/prefect/server/database/query_components.py:422: error: Incompatible types in assignment (expression has type "CTE", variable has type "Select") [assignment]
+ src/prefect/server/models/block_registration.py:137: error: "SessionTransaction" has no attribute "__aenter__" [attr-defined]
+ src/prefect/server/models/block_registration.py:137: error: "SessionTransaction" has no attribute "__aexit__" [attr-defined]
+ src/prefect/server/models/block_registration.py:159: error: "SessionTransaction" has no attribute "__aenter__" [attr-defined]
+ src/prefect/server/models/block_registration.py:159: error: "SessionTransaction" has no attribute "__aexit__" [attr-defined]
+ src/prefect/server/models/block_documents.py:306: error: Incompatible types in assignment (expression has type "CTE", variable has type "Select") [assignment]
ibis (https://github.com/ibis-project/ibis)
+ ibis/backends/base/sql/alchemy/registry.py:21: error: Incompatible types in assignment (expression has type "String", base class "GenericFunction" defined the type as "Callable[[GenericFunction], Union[TypeEngine, Type[TypeEngine]]]") [assignment]
- ibis/backends/base/sql/alchemy/datatypes.py:20: error: Module has no attribute "to_instance" [attr-defined]
- ibis/backends/base/sql/alchemy/datatypes.py:44: error: Module has no attribute "to_instance" [attr-defined]
- ibis/backends/base/sql/alchemy/datatypes.py:60: error: Module has no attribute "to_instance" [attr-defined]
- ibis/backends/base/sql/alchemy/datatypes.py:61: error: Module has no attribute "to_instance" [attr-defined]
+ ibis/backends/base/sql/alchemy/__init__.py:152: error: Module has no attribute "registry" [attr-defined]
+ ibis/backends/base/sql/alchemy/__init__.py:527: error: List item 1 has incompatible type "str"; expected "None" [list-item]
+ ibis/backends/druid/__init__.py:51: error: Incompatible types in assignment (expression has type "Callable[[Any, str, Any], bool]", variable has type "Callable[[Any, Any, Optional[Any], KwArg(Any)], bool]") [assignment]
- ibis/backends/snowflake/__init__.py:153: error: Module has no attribute "to_instance" [attr-defined]
- ibis/backends/snowflake/__init__.py:439: error: Module has no attribute "to_instance" [attr-defined]
- ibis/backends/druid/__init__.py:51: error: Incompatible types in assignment (expression has type "Callable[[Any, str, Any], bool]", variable has type "Callable[[Any, Any, Optional[Any], KwArg(Any)], None]") [assignment]
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Includes #9596 and #9568, so merge those first. (keeping this as draft until then, I've also yet to self-review my own PR with a fresh mind)If you'd like me to split up this PR (maybe you'd like to review a specific section in isolation) and you can think of a decent way to do so, let me know.
In the same vein, I'd rather not add more type-hints, even if they seem obvious (unless it's to fix an issue). I would consider it scope-creeping given the motivation behind this PR: #9595 (comment)
Brings
types-sqlalchemy
on par with https://github.com/microsoft/python-type-stubs/tree/main/sqlalchemy and https://github.com/dropbox/sqlalchemy-stubs. Except for making most classes (mainlyColumn
andRow
related ones) generic. As that would cause hundreds, if not thousands of additional (and unhelpful)mypy_primer
differences. It also helps keep this PR more manageable and focus on the non-generic type issues.Merged stubs, avoided new generics, manually reviewed possible types and fixed existing type issues I found.
Standardized imports (relative seems to be preferred for this stub) and fixed a handful of pytype references issues with imports. (google/pytype#1087)
I tried my best to fully comment the confusing parts.