Only import sqlite3 when type checking (#7155)

Fixes: #7127
Signed-off-by: David Vo <david@vovo.id.au>
This commit is contained in:
David Vo 2020-03-28 00:20:00 +11:00 committed by GitHub
parent 7496d3d2f6
commit fbf0782c63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

1
changelog.d/7155.bugfix Normal file
View file

@ -0,0 +1 @@
Avoid importing `sqlite3` when using the postgres backend. Contributed by David Vo.

View file

@ -12,14 +12,17 @@
# 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.
import sqlite3
import struct
import threading
import typing
from synapse.storage.engines import BaseDatabaseEngine
if typing.TYPE_CHECKING:
import sqlite3 # noqa: F401
class Sqlite3Engine(BaseDatabaseEngine[sqlite3.Connection]):
class Sqlite3Engine(BaseDatabaseEngine["sqlite3.Connection"]):
def __init__(self, database_module, database_config):
super().__init__(database_module, database_config)