Skip to content

Remove Flask-SQLAlchemy #9989

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
wants to merge 4 commits into from
Closed

Remove Flask-SQLAlchemy #9989

wants to merge 4 commits into from

Conversation

sobolevn
Copy link
Member

Closes #8885

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, will merge on 1 April

@AlexWaygood
Copy link
Member

Oh, looks like the way Flask-SQLAlchemy is packaged breaks some of the logic for dealing with non-types dependencies in pytype_test.py ://

@sobolevn
Copy link
Member Author

sobolevn commented Mar 30, 2023

I will take a look later, there are two unrelated problems.
pytype fails because of top_level.txt
and pyright is just not happy with some types

@AlexWaygood
Copy link
Member

The pyright stuff is very strange. It's erroring out on some types in stubs/SQLAlchemy. But you haven't changed anything in that directory!

@github-actions

This comment has been minimized.

# Requires a version of flask with a `py.typed` file
requires = ["Flask>=2.0.0", "types-Flask-SQLAlchemy"]
# Requires versions of flask/Flask-SQLAlchemy with `py.typed` files
requires = ["Flask>=2.0.0", "Flask-SQLAlchemy>=3.0.1"]
Copy link
Member

@AlexWaygood AlexWaygood Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it out. Because you're specifying Flask-SQLAlchemy as a dependency of types-Flask-Migrate, that then pulls in SQLAlchemy as a transitive dependency of types-Flask-Migrate (because SQLAlchemy is a dependency of Flask-SQLAlchemy). That means pip now install SQLAlchemy in CI before pyright tests any of the stubs and, because it's unpinned, pip installs the latest version of SQLAlchemy available. Because SQLAlchemy>=2 has inline types and a py.typed file, that means that pyright is now pointing out the inconsistencies between our stubs for SQLAlchemy<2 and the inline types it sees the site-packages directory for SQLAlchemy>=2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to fix this is another question. I'm open to ideas ://

Copy link
Collaborator

@Avasam Avasam Apr 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just add the missing generics. So that the stubs are on par enough with the 2.0 version for this PR to pass.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just add the missing generics. So that the stubs are on par enough with the 2.0 version for this PR to pass.

It feels like a somewhat fragile solution -- if SQLAlchemy makes more stuff generic on the 2.0 branch that isn't generic in our stubs for SQLAlchemy 1.0, and they then make a release, our CI will break unexpectedly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I think just waiting to remove them together, given their co-dependencies, just makes the most sense.

@AlexWaygood
Copy link
Member

AlexWaygood commented Apr 2, 2023

An easy way of solving the pyright issue, given our Sqlalchemy stubs are already marked as obsolete, would be to just wait until we're ready to remove those stubs, and then remove them both together

AlexWaygood added a commit to AlexWaygood/stub_uploader that referenced this pull request Apr 30, 2023
Needed for python/typeshed#9989. There are other blockers on that PR at the moment, but we will *eventually* want to have our stubs for `Flask-Migrate` declare a dependency on `Flask-SQLAlchemy`, even if we have to wait a little bit before we're able to do that.
srittau pushed a commit to typeshed-internal/stub_uploader that referenced this pull request May 3, 2023
Needed for python/typeshed#9989. There are other blockers on that PR at the moment, but we will *eventually* want to have our stubs for `Flask-Migrate` declare a dependency on `Flask-SQLAlchemy`, even if we have to wait a little bit before we're able to do that.
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

kornia (https://github.com/kornia/kornia) got 3.52x faster (7.1s -> 2.0s)

@AlexWaygood
Copy link
Member

AlexWaygood commented Jul 1, 2023

Closing, as this can only be done at the same time as removing our SQLAlchemy stubs, and we've got #10389 open for that now

(There's also a ton of merge conflicts now!)

@AlexWaygood AlexWaygood closed this Jul 1, 2023
@AlexWaygood AlexWaygood deleted the issue-8885 branch July 1, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Flask-SQLAlchemy stubs (not until April 2023)
3 participants