@@ -52,20 +52,17 @@ class SSLNegotiation(compat.StrEnum):
52
52
direct = "direct"
53
53
54
54
55
- _ConnectionParameters = collections .namedtuple (
56
- 'ConnectionParameters' ,
57
- [
58
- 'user' ,
59
- 'password' ,
60
- 'database' ,
61
- 'ssl' ,
62
- 'sslmode' ,
63
- 'ssl_negotiation' ,
64
- 'server_settings' ,
65
- 'target_session_attrs' ,
66
- 'krbsrvname' ,
67
- 'gsslib' ,
68
- ])
55
+ class _ConnectionParameters (typing .NamedTuple ):
56
+ user : str
57
+ password : typing .Optional [str ]
58
+ database : str
59
+ ssl : typing .Union [ssl_module .SSLContext , bool , str , SSLMode , None ]
60
+ sslmode : SSLMode
61
+ ssl_negotiation : SSLNegotiation
62
+ server_settings : typing .Optional [typing .Dict [str , str ]]
63
+ target_session_attrs : "SessionAttribute"
64
+ krbsrvname : typing .Optional [str ]
65
+ gsslib : str
69
66
70
67
71
68
_ClientConfiguration = collections .namedtuple (
@@ -276,10 +273,25 @@ def _dot_postgresql_path(filename) -> typing.Optional[pathlib.Path]:
276
273
return (homedir / '.postgresql' / filename ).resolve ()
277
274
278
275
279
- def _parse_connect_dsn_and_args (* , dsn , host , port , user ,
280
- password , passfile , database , ssl ,
281
- direct_tls , server_settings ,
282
- target_session_attrs , krbsrvname , gsslib ):
276
+ def _parse_connect_dsn_and_args (
277
+ * ,
278
+ dsn : str ,
279
+ host : typing .Union [str , typing .List [str ], typing .Tuple [str ]],
280
+ port : typing .Union [int , typing .List [int ]],
281
+ user : typing .Optional [str ],
282
+ password : typing .Optional [str ],
283
+ passfile : typing .Union [str , pathlib .Path , None ],
284
+ database : typing .Optional [str ],
285
+ ssl : typing .Union [bool , None , str , SSLMode ],
286
+ direct_tls : typing .Optional [bool ],
287
+ server_settings : typing .Optional [typing .Dict [str , str ]],
288
+ target_session_attrs : typing .Optional [str ],
289
+ krbsrvname : typing .Optional [str ],
290
+ gsslib : typing .Optional [str ],
291
+ ) -> typing .Tuple [
292
+ typing .List [typing .Union [str , typing .Tuple [str , int ]]],
293
+ _ConnectionParameters ,
294
+ ]:
283
295
# `auth_hosts` is the version of host information for the purposes
284
296
# of reading the pgpass file.
285
297
auth_hosts = None
@@ -502,7 +514,7 @@ def _parse_connect_dsn_and_args(*, dsn, host, port, user,
502
514
database = database , user = user ,
503
515
passfile = passfile )
504
516
505
- addrs = []
517
+ addrs : typing . List [ typing . Union [ str , typing . Tuple [ str , int ]]] = []
506
518
have_tcp_addrs = False
507
519
for h , p in zip (host , port ):
508
520
if h .startswith ('/' ):
0 commit comments