Backport PR #40471: compat: sqlalchemy deprecations
Backport PR #40471
I'll merge this for now pending further investigation, the pre-commit checks passed locally before pushing this PR.

In general we don't do style backports, so we maybe need to pin versions for pre-commit on 1.2.x cc @MarcoGorelli  > In general we don't do style backports, so we maybe need to pin versions for pre-commit on 1.2.x cc @MarcoGorelli

@MarcoGorelli I can now replicate locally after doing a pre-commit clean. Strange that yesqa is now failing when that has a pinned version.

I'll just open a PR directly against 1.2.x with the trivial changes required rather than investigating this further. > I'll just open a PR directly against 1.2.x with the trivial changes required rather than investigating this further.

urgh. not straightforward. flake8 fails if apply the yesqa changes. looks like adding `additional_dependencies: [flake8==3.8.4]` may fix it. 