matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Bump types-psycopg2 from 2.9.21.11 to 2.9.21.13 #16343

Closed dependabot[bot] closed 1 year ago

dependabot[bot] commented 1 year ago

Bumps types-psycopg2 from 2.9.21.11 to 2.9.21.13.

Commits


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
DMRobertson commented 1 year ago
 synapse/storage/engines/postgres.py:35: error: Type argument "connection" of "BaseDatabaseEngine" must be a subtype of "Connection"  [type-var]
synapse/storage/engines/postgres.py:35: error: Type argument "cursor" of "BaseDatabaseEngine" must be a subtype of "Cursor"  [type-var]
synapse/storage/engines/postgres.py:105: error: Argument 1 to "get_db_locale" of "PostgresEngine" has incompatible type "cursor"; expected "Cursor"  [arg-type]
synapse/storage/engines/postgres.py:105: note: Following member(s) of "cursor" have conflicts:
synapse/storage/engines/postgres.py:105: note:     description: expected "Optional[Sequence[Tuple[str, Optional[Any], Optional[int], Optional[int], Optional[int], Optional[int], Optional[int]]]]", got "Optional[Tuple[Column, ...]]"
synapse/storage/engines/postgres.py:132: error: Argument 1 of "check_new_database" is incompatible with supertype "BaseDatabaseEngine"; supertype defines the argument type as "cursor"  [override]
synapse/storage/engines/postgres.py:132: note: This violates the Liskov substitution principle
synapse/storage/engines/postgres.py:132: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
tests/server.py:1030: error: Subclass of "Connection" and "connection" cannot exist: would have incompatible method signatures  [unreachable]
tests/server.py:1031: error: Statement is unreachable  [unreachable]
tests/server.py:1077: error: Subclass of "Connection" and "connection" cannot exist: would have incompatible method signatures  [unreachable]
tests/server.py:1078: error: Statement is unreachable  [unreachable]
DMRobertson commented 1 year ago

https://github.com/python/typeshed/commits/main/stubs/psycopg2 for recent changes

DMRobertson commented 1 year ago

Guessing that this is https://github.com/python/typeshed/pull/10630.

I think the problem is that I wrote a protocol for Cursor.description

https://github.com/matrix-org/synapse/blob/8a47d6e3a685bd45237b7dae9c138209df509f64/synapse/storage/types.py#L53-L72

based on https://peps.python.org/pep-0249/#description. But psycopg2 uses a Column type: https://github.com/python/typeshed/blame/d56b0b80d80d4736a21c0dfcc186dfd3ad152bf5/stubs/psycopg2/psycopg2/_psycopg.pyi#L179, rather than an inner tuple like sqlite3: https://github.com/python/typeshed/blob/d56b0b80d80d4736a21c0dfcc186dfd3ad152bf5/stdlib/sqlite3/dbapi2.pyi#L400. (Column defines a getitem so it presumably still looks like a tuple?)

So now mypy can see that psycopg.extensions.cursor doesn't satisfy the protocol I wrote.

I can't see a clean way to fix this, and there's only one call site: https://github.com/matrix-org/synapse/blob/2a0f86f88fdb3d450212541ba7db57df6a184ae3/synapse/storage/database.py#L1045-L1057

So I'm going to just change description to be Sequence[Any].

dependabot[bot] commented 1 year ago

A newer version of types-psycopg2 exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

clokep commented 1 year ago

@DMRobertson Is it worth recreating this to see if it works better?

DMRobertson commented 1 year ago

@DMRobertson Is it worth recreating this to see if it works better?

I'd be surprised if it worked without the tweak I added in 3049b8e (#16343), but I'm happy to recreate it and try. We can always resurrect or cherry-pick that change.

DMRobertson commented 1 year ago

@dependabot recreate

dependabot[bot] commented 1 year ago

Superseded by #16381.