Pre-emptively fix synapse.storage.types.Connection for future mypy release (#8577)

Fix the Connection protocol according to typeshed's assertions about sqlite3.Connection
This commit is contained in:
Jonathan de Jong 2020-10-17 10:51:38 +02:00 committed by GitHub
parent 0afd83584b
commit 79c1f973ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

1
changelog.d/8577.misc Normal file
View File

@ -0,0 +1 @@
Adjust a protocol-type definition to fit `sqlite3` assertions.

View File

@ -160,7 +160,7 @@ class LoggingDatabaseConnection:
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.

View File

@ -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
@ -65,5 +65,5 @@ class Connection(Protocol):
def __enter__(self) -> "Connection":
...
def __exit__(self, exc_type, exc_value, traceback) -> bool:
def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]:
...