Skip to content

Conversation

miketheman
Copy link
Member

See commits for specifics.

Address ~500 warnings surfaced by setting SQLALCHEMY_WARN_20=1 during the test suite.

There's still some 4,000 left, but I wanted to get these out.

Please review carefully!

Resolves:

```
MovedIn20Warning: The ``declarative_base()`` function is now available
as sqlalchemy.orm.declarative_base(). (deprecated since: 1.4)
(Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
```

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Resolves:

```
RemovedIn20Warning: Passing a string to Connection.execute() is
deprecated and will be removed in version 2.0. Use the text() construct,
or the Connection.exec_driver_sql() method to invoke a driver-level SQL string.
```

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Resolves:

```
LegacyAPIWarning: The Query.get() method is considered legacy as of
the 1.x series of SQLAlchemy and becomes a legacy construct in 2.0.
The method is now available as Session.get() (deprecated since: 1.4)
```

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@miketheman miketheman requested a review from a team as a code owner April 25, 2023 04:10
Copy link
Member

@di di left a comment

Choose a reason for hiding this comment

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

Just an idle thought: I bet we have a few instances of db.query(Model).filter(Model.id == id).one() that could be replaced with db.get(Model, id)

@miketheman
Copy link
Member Author

Just an idle thought: I bet we have a few instances of db.query(Model).filter(Model.id == id).one() that could be replaced with db.get(Model, id)

We absolutely do - I found a few in banner.py and sponsors.py - I might refactor those in the next round.

@miketheman miketheman merged commit a4058e3 into pypi:main May 1, 2023
@miketheman miketheman deleted the sqlalchemy-warnings branch May 1, 2023 15:06
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.

2 participants