From 2bbf6c76766b1852a7b3247e450b08233caa8933 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Fri, 16 Oct 2020 22:36:41 +0200 Subject: [PATCH 1/4] Fix the Connection protocol according to typeshed's assertions about sqlite3.Connection --- synapse/storage/database.py | 2 +- synapse/storage/types.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/storage/database.py b/synapse/storage/database.py index 763722d6bce6..f777d5cf1a90 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -160,7 +160,7 @@ def __enter__(self) -> "Connection": self.conn.__enter__() return self - def __exit__(self, exc_type, exc_value, traceback) -> bool: + def __exit__(self, exc_type, exc_value, traceback) -> None: return self.conn.__exit__(exc_type, exc_value, traceback) # Proxy through any unknown lookups to the DB conn class. diff --git a/synapse/storage/types.py b/synapse/storage/types.py index 970bb1b9da35..7f8ff8a0a86d 100644 --- a/synapse/storage/types.py +++ b/synapse/storage/types.py @@ -65,5 +65,5 @@ def rollback(self, *args, **kwargs) -> None: def __enter__(self) -> "Connection": ... - def __exit__(self, exc_type, exc_value, traceback) -> bool: + def __exit__(self, exc_type, exc_value, traceback) -> None: ... From a4a88be76d4296f8f618d216e4e860e1b9b964ce Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Fri, 16 Oct 2020 22:49:30 +0200 Subject: [PATCH 2/4] add news --- changelog.d/8577.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/8577.misc diff --git a/changelog.d/8577.misc b/changelog.d/8577.misc new file mode 100644 index 000000000000..75fe563a0258 --- /dev/null +++ b/changelog.d/8577.misc @@ -0,0 +1 @@ +Adjust a protocol-type definition to fit `sqlite3` assertions. \ No newline at end of file From ac53a6b7e4f5654c64466de3d9169da89d36dc23 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Fri, 16 Oct 2020 23:08:53 +0200 Subject: [PATCH 3/4] Change None to Optional[bool] --- synapse/storage/database.py | 2 +- synapse/storage/types.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/storage/database.py b/synapse/storage/database.py index f777d5cf1a90..0217e631085a 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py @@ -160,7 +160,7 @@ def __enter__(self) -> "Connection": self.conn.__enter__() return self - def __exit__(self, exc_type, exc_value, traceback) -> None: + def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]: return self.conn.__exit__(exc_type, exc_value, traceback) # Proxy through any unknown lookups to the DB conn class. diff --git a/synapse/storage/types.py b/synapse/storage/types.py index 7f8ff8a0a86d..d32439a7e72e 100644 --- a/synapse/storage/types.py +++ b/synapse/storage/types.py @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Iterable, Iterator, List, Tuple +from typing import Any, Iterable, Iterator, List, Tuple, Optional from typing_extensions import Protocol @@ -65,5 +65,5 @@ def rollback(self, *args, **kwargs) -> None: def __enter__(self) -> "Connection": ... - def __exit__(self, exc_type, exc_value, traceback) -> None: + def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]: ... From fe19504bc719d7c7d88072e94efb6372e60f7503 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Fri, 16 Oct 2020 23:21:14 +0100 Subject: [PATCH 4/4] Update synapse/storage/types.py --- synapse/storage/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/storage/types.py b/synapse/storage/types.py index d32439a7e72e..9cadcba18fc0 100644 --- a/synapse/storage/types.py +++ b/synapse/storage/types.py @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Iterable, Iterator, List, Tuple, Optional +from typing import Any, Iterable, Iterator, List, Optional, Tuple from typing_extensions import Protocol