scripts: Help mypy resolve the psycopg2.connect overload.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-08-30 13:38:45 -07:00 committed by Tim Abbott
parent 4fb97576e9
commit 5d77d50423
2 changed files with 6 additions and 3 deletions

View File

@ -172,7 +172,8 @@ if options.nagios_check:
pg_args["user"] = options.nagios_user pg_args["user"] = options.nagios_user
else: else:
del pg_args["user"] del pg_args["user"]
conn = psycopg2.connect(**pg_args) # connection_factory=None lets mypy understand the return type
conn = psycopg2.connect(connection_factory=None, **pg_args)
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("SELECT count(*) FROM fts_update_log") cursor.execute("SELECT count(*) FROM fts_update_log")
num = cursor.fetchall()[0][0] num = cursor.fetchall()[0][0]
@ -199,7 +200,8 @@ retries = 1
while True: while True:
try: try:
if conn is None: if conn is None:
conn = psycopg2.connect(**pg_args) # connection_factory=None lets mypy understand the return type
conn = psycopg2.connect(connection_factory=None, **pg_args)
cursor = conn.cursor() cursor = conn.cursor()
retries = 30 retries = 30

View File

@ -44,7 +44,8 @@ pg_args["dbname"] = settings.DATABASES["default"]["NAME"]
pg_args["sslmode"] = settings.DATABASES["default"]["OPTIONS"].get("sslmode") pg_args["sslmode"] = settings.DATABASES["default"]["OPTIONS"].get("sslmode")
pg_args["connect_timeout"] = "600" pg_args["connect_timeout"] = "600"
conn = psycopg2.connect(**pg_args) # connection_factory=None lets mypy understand the return type
conn = psycopg2.connect(connection_factory=None, **pg_args)
conn.autocommit = True conn.autocommit = True
pg_server_version = conn.server_version pg_server_version = conn.server_version