-
Notifications
You must be signed in to change notification settings - Fork 100
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
SQLAlchemy 2: Fix failing mypy checks from development #257
Merged
Conversation
This file contains 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
Signed-off-by: Jesse Whitehouse <[email protected]>
mypy doesn't like wildcard imports, but they are necessary here and con -sistent with SQLAlchemy's guidance for structuring tests Signed-off-by: Jesse Whitehouse <[email protected]>
I changed the format of the output of dialect._describe_table_extended to return a list of dicts rather than a list of lists but didn't update this type hint Signed-off-by: Jesse Whitehouse <[email protected]>
This method doesn't handle cases where the regex doesn't match anything Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
base.py. I re-ran HasTableTest which depend on this working to confirm that it does not cause a regression. Signed-off-by: Jesse Whitehouse <[email protected]>
I'm not clear how to instruct mypy to know that the value of `result` will never be None given the way we called _describe_table_extended Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
mypy doesn't understand that describe_table_extended will never return a NoneType under these circumstances Signed-off-by: Jesse Whitehouse <[email protected]>
Not sure how we can actually match the interface mypy expects Signed-off-by: Jesse Whitehouse <[email protected]>
Signed-off-by: Jesse Whitehouse <[email protected]>
susodapop
requested review from
arikfr,
yunbodeng-db and
andrefurlan-db
as code owners
October 23, 2023 20:27
benc-db
approved these changes
Oct 23, 2023
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.
Description
Now that we've implemented SQLAlchemy 2 support, I'm cleaning up the failing mypy checks. There are three broad kinds of fixes here:
sqlalchemy.interfaces
In one case, I modified the actual behaviour of the dialect in order to keep the type hints as-is. I did this by moving a call to
.all()
on a CursorResult from the top-level method inbase.py
into the _parse method that it depends on.This will fix the failing mypy checks on
main
which have been entirely driven by SQLAlchemy development. For future features like this, we should use a staging branch so thatmain
doesn't fail for unreleased features.sqlalchemy.interfaces
In the top-level dialect in
base.py
I use the type hints that SQLAlchemy expects internally. Although these aren't enforced by Python, it's useful for developers reading the source to understand what's happening when methods likeget_foreign_keys
andget_pk_constraint
is called. Rather than update the type hints to something mypy can parse, I left the hints as-is. We should figure out how to write these methods in a way that actually enforces the interface.