Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Pre-emptively fix synapse.storage.types.Connection for future mypy re…
Browse files Browse the repository at this point in the history
…lease (#8577)

Fix the Connection protocol according to typeshed's assertions about sqlite3.Connection
  • Loading branch information
ShadowJonathan authored Oct 17, 2020
1 parent 0afd835 commit 79c1f97
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/8577.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adjust a protocol-type definition to fit `sqlite3` assertions.
2 changes: 1 addition & 1 deletion synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> Optional[bool]:
return self.conn.__exit__(exc_type, exc_value, traceback)

# Proxy through any unknown lookups to the DB conn class.
Expand Down
4 changes: 2 additions & 2 deletions synapse/storage/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, Optional, Tuple

from typing_extensions import Protocol

Expand Down Expand Up @@ -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) -> Optional[bool]:
...

0 comments on commit 79c1f97

Please sign in to comment.