This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 15
15
from enum import IntEnum
16
16
from typing import Generic , Optional , TypeVar
17
17
18
- from synapse .storage .types import Connection
18
+ from synapse .storage .types import Connection , DBAPI2Module
19
19
20
20
21
21
class IsolationLevel (IntEnum ):
@@ -32,7 +32,7 @@ class IncorrectDatabaseSetup(RuntimeError):
32
32
33
33
34
34
class BaseDatabaseEngine (Generic [ConnectionType ], metaclass = abc .ABCMeta ):
35
- def __init__ (self , module ):
35
+ def __init__ (self , module : DBAPI2Module ):
36
36
self .module = module
37
37
38
38
@property
Original file line number Diff line number Diff line change @@ -94,3 +94,23 @@ def __exit__(
94
94
traceback : Optional [TracebackType ],
95
95
) -> Optional [bool ]:
96
96
...
97
+
98
+
99
+ class DBAPI2Module (Protocol ):
100
+ """The module-level attributes that we use from PEP 249.
101
+
102
+ This is NOT a comprehensive stub for the entire DBAPI2."""
103
+
104
+ __name__ : str
105
+
106
+ Warning : Type [Exception ]
107
+ Error : Type [Exception ]
108
+ DatabaseError : Type [Exception ]
109
+ OperationalError : Type [Exception ]
110
+ IntegrityError : Type [Exception ]
111
+
112
+ def connect (self , ** parameters : object ) -> Connection :
113
+ ...
114
+
115
+
116
+ __all__ = ["Cursor" , "Connection" , "DBAPI2Module" ]
You can’t perform that action at this time.
0 commit comments