1212)
1313from psycopg2 .extras import RealDictCursor # type: ignore
1414
15- # no stubs available, starting out by just determining correct return
16- # types & annotating in my wrappers here
17- import aiopg # type: ignore
15+ import aiopg
1816
1917LOGGER = logging .getLogger (__name__ )
2018
@@ -40,14 +38,15 @@ async def _try_connect(
4038 host = connection_params .host
4139 port = connection_params .port
4240
43- dsn = f'dbname={ database } user={ user } password={ password } host={ host } port={ port } '
41+ dsn = f"dbname={ database } user={ user } password={ password } " \
42+ f"host={ host } port={ port } "
4443
4544 # PENDS python 3.9 support in pylint
4645 # pylint: disable=unsubscriptable-object
4746 connection : Optional [aiopg .Connection ] = None
4847
49- LOGGER .info (
50- f'Attempting to connect to database { database } as { user } @{ host } :{ port } ...' )
48+ LOGGER .info (f"Attempting to connect to database { database } as "
49+ f" { user } @{ host } :{ port } ..." )
5150
5251 while connection is None :
5352 try :
@@ -58,12 +57,12 @@ async def _try_connect(
5857 print (type (err ))
5958 if retries > 12 :
6059 raise ConnectionError (
61- ' Max number of connection attempts has been reached (12)'
60+ " Max number of connection attempts has been reached (12)"
6261 ) from err
6362
6463 LOGGER .info (
65- f' Connection failed ({ retries } time(s))'
66- ' retrying again in 5 seconds...' )
64+ f" Connection failed ({ retries } time(s))"
65+ " retrying again in 5 seconds..." )
6766
6867 await asyncio .sleep (5 )
6968 return await _try_connect (connection_params , retries + 1 )
@@ -81,12 +80,13 @@ def _sync_try_connect(
8180 host = connection_params .host
8281 port = connection_params .port
8382
84- dsn = f'dbname={ database } user={ user } password={ password } host={ host } port={ port } '
83+ dsn = f"dbname={ database } user={ user } password={ password } " + \
84+ f"host={ host } port={ port } "
8585
8686 connection : Optional [Any ] = None
8787
88- LOGGER .info (
89- f'Attempting to connect to database { database } as { user } @{ host } :{ port } ...' )
88+ LOGGER .info (f"Attempting to connect to database { database } "
89+ f" as { user } @{ host } :{ port } ..." )
9090
9191 while connection is None :
9292 try :
@@ -97,12 +97,12 @@ def _sync_try_connect(
9797 print (type (err ))
9898 if retries > 12 :
9999 raise ConnectionError (
100- ' Max number of connection attempts has been reached (12)'
100+ " Max number of connection attempts has been reached (12)"
101101 ) from err
102102
103103 LOGGER .info (
104- f' Connection failed ({ retries } time(s))'
105- ' retrying again in 5 seconds...' )
104+ f" Connection failed ({ retries } time(s))"
105+ " retrying again in 5 seconds..." )
106106
107107 time .sleep (5 )
108108 return _sync_try_connect (connection_params , retries + 1 )
0 commit comments