From 790289b33d86260fa8d67b72c0a4829f5c9901a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:09:23 +0000 Subject: [PATCH 1/4] Bump types-psycopg2 from 2.9.21.11 to 2.9.21.14 Bumps [types-psycopg2](https://github.com/python/typeshed) from 2.9.21.11 to 2.9.21.14. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-psycopg2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 6f451106ec6b..5cde6fd145d8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3004,13 +3004,13 @@ files = [ [[package]] name = "types-psycopg2" -version = "2.9.21.11" +version = "2.9.21.14" description = "Typing stubs for psycopg2" optional = false python-versions = "*" files = [ - {file = "types-psycopg2-2.9.21.11.tar.gz", hash = "sha256:d5077eacf90e61db8c0b8eea2fdc9d4a97d7aaa16865fb4bd7034a7571520b4d"}, - {file = "types_psycopg2-2.9.21.11-py3-none-any.whl", hash = "sha256:7a323d7744bc8a882fb5a6f63448e903fc70d3dc0d6da9ec1f9c6c4dc10a7102"}, + {file = "types-psycopg2-2.9.21.14.tar.gz", hash = "sha256:bf73a0ac4da4e278c89bf1b01fc596d5a5ac7a356cfe6ac0249f47b9e259f868"}, + {file = "types_psycopg2-2.9.21.14-py3-none-any.whl", hash = "sha256:cd9c5350631f3bc6184ec8d48f2ed31d4ea660f89d0fffe78239450782f383c5"}, ] [[package]] From ee8f0dc3e432603f16857774cb73a2a6a0183e46 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 19 Sep 2023 17:56:30 +0100 Subject: [PATCH 2/4] Relax the annotation of Cursor.description See https://github.com/matrix-org/synapse/pull/16343#issuecomment-1726083384 for rationale. --- synapse/storage/database.py | 14 +------------- synapse/storage/types.py | 20 ++++---------------- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 697bc5651c91..ca894edd5ad3 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -361,19 +361,7 @@ def rowcount(self) -> int: @property def description( self, - ) -> Optional[ - Sequence[ - Tuple[ - str, - Optional[Any], - Optional[int], - Optional[int], - Optional[int], - Optional[int], - Optional[int], - ] - ] - ]: + ) -> Optional[Sequence[Any]]: return self.txn.description def execute_batch(self, sql: str, args: Iterable[Iterable[Any]]) -> None: diff --git a/synapse/storage/types.py b/synapse/storage/types.py index 34ac80753012..afaeef9a5a36 100644 --- a/synapse/storage/types.py +++ b/synapse/storage/types.py @@ -53,22 +53,10 @@ def fetchall(self) -> List[Tuple]: @property def description( self, - ) -> Optional[ - Sequence[ - # Note that this is an approximate typing based on sqlite3 and other - # drivers, and may not be entirely accurate. - # FWIW, the DBAPI 2 spec is: https://peps.python.org/pep-0249/#description - Tuple[ - str, - Optional[Any], - Optional[int], - Optional[int], - Optional[int], - Optional[int], - Optional[int], - ] - ] - ]: + ) -> Optional[Sequence[Any]]: + # At the time of writing, Synapse only assumes that `column[0]: str` for each + # `column in description`. Since this is hard to express in the type system, and + # as this is rarely used in Synapse, we deem `column: Any` good enough. ... @property From a60ac2c1256076127969e9557ec318fbdc5715ec Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 25 Sep 2023 17:15:26 +0100 Subject: [PATCH 3/4] Changelog --- changelog.d/16831.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/16831.misc diff --git a/changelog.d/16831.misc b/changelog.d/16831.misc new file mode 100644 index 000000000000..a45465195273 --- /dev/null +++ b/changelog.d/16831.misc @@ -0,0 +1 @@ +Improve type hints, and bump types-psycopg2 from 2.9.21.11 to 2.9.21.14. From 21357929643e743d38fc56d8ccf25b300d508c71 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 25 Sep 2023 17:22:03 +0100 Subject: [PATCH 4/4] Changelog --- changelog.d/{16831.misc => 16381.misc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{16831.misc => 16381.misc} (100%) diff --git a/changelog.d/16831.misc b/changelog.d/16381.misc similarity index 100% rename from changelog.d/16831.misc rename to changelog.d/16381.misc