From: Denis Laxalde Date: Tue, 2 Nov 2021 14:19:57 +0000 (+0100) Subject: Make spiketest.py script mypy-clean X-Git-Tag: 3.0.2~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37c8905186f53a1f89e8e349ed00aa23bfd7d956;p=thirdparty%2Fpsycopg.git Make spiketest.py script mypy-clean - allow untyped defs/calls (as everywhere else in tests/*) - avoid list comprehension filled with no value - add a type variable to Connection subclass - drop useless sys.exit() call, since main() does not return a value --- diff --git a/tests/scripts/spiketest.py b/tests/scripts/spiketest.py index e26d91bf7..6de342970 100644 --- a/tests/scripts/spiketest.py +++ b/tests/scripts/spiketest.py @@ -8,18 +8,20 @@ The test is inspired to the `spike analysis`__ illustrated by HikariCP Welcome-To-The-Jungle.md """ +# mypy: allow-untyped-defs +# mypy: allow-untyped-calls -import sys import time import threading import psycopg import psycopg_pool +from psycopg.rows import Row import logging -def main(): +def main() -> None: opt = parse_cmdline() if opt.loglevel: loglevel = getattr(logging, opt.loglevel.upper()) @@ -47,7 +49,8 @@ def main(): ) for i in range(opt.num_clients) ] - [t.start() for t in threads] + for t in threads: + t.start() time.sleep(0.2) # Release the threads! @@ -56,7 +59,8 @@ def main(): ev.set() # Wait for the threads to finish - [t.join() for t in threads] + for t in threads: + t.join() t1 = time.time() measurer.stop() @@ -103,7 +107,7 @@ class Measurer: time.sleep(interval) -class DelayedConnection(psycopg.Connection): +class DelayedConnection(psycopg.Connection[Row]): """A connection adding a delay to the connection time.""" @classmethod @@ -155,4 +159,4 @@ def parse_cmdline(): if __name__ == "__main__": - sys.exit(main()) + main()