@@ -119,18 +119,21 @@ class ClientSession:
119
119
def __init__ (
120
120
self ,
121
121
user : str ,
122
- authorization_user : str = None ,
123
- catalog : str = None ,
124
- schema : str = None ,
125
- source : str = None ,
126
- properties : Dict [str , str ] = None ,
127
- headers : Dict [str , str ] = None ,
128
- transaction_id : str = None ,
129
- extra_credential : List [Tuple [str , str ]] = None ,
130
- client_tags : List [str ] = None ,
131
- roles : Union [Dict [str , str ], str ] = None ,
132
- timezone : str = None ,
122
+ authorization_user : Optional [ str ] = None ,
123
+ catalog : Optional [ str ] = None ,
124
+ schema : Optional [ str ] = None ,
125
+ source : Optional [ str ] = None ,
126
+ properties : Optional [ Dict [str , str ] ] = None ,
127
+ headers : Optional [ Dict [str , str ] ] = None ,
128
+ transaction_id : Optional [ str ] = None ,
129
+ extra_credential : Optional [ List [Tuple [str , str ] ]] = None ,
130
+ client_tags : Optional [ List [str ] ] = None ,
131
+ roles : Optional [ Union [Dict [str , str ], str ] ] = None ,
132
+ timezone : Optional [ str ] = None ,
133
133
):
134
+ self ._object_lock = threading .Lock ()
135
+ self ._prepared_statements : Dict [str , str ] = {}
136
+
134
137
self ._user = user
135
138
self ._authorization_user = authorization_user
136
139
self ._catalog = catalog
@@ -142,107 +145,106 @@ def __init__(
142
145
self ._extra_credential = extra_credential
143
146
self ._client_tags = client_tags .copy () if client_tags is not None else list ()
144
147
self ._roles = self ._format_roles (roles ) if roles is not None else {}
145
- self ._prepared_statements : Dict [str , str ] = {}
146
- self ._object_lock = threading .Lock ()
147
148
self ._timezone = timezone or get_localzone_name ()
148
149
if timezone : # Check timezone validity
149
150
ZoneInfo (timezone )
150
151
151
152
@property
152
- def user (self ):
153
+ def user (self ) -> str :
153
154
return self ._user
154
155
155
156
@property
156
- def authorization_user (self ):
157
+ def authorization_user (self ) -> Optional [ str ] :
157
158
with self ._object_lock :
158
159
return self ._authorization_user
159
160
160
161
@authorization_user .setter
161
- def authorization_user (self , authorization_user ) :
162
+ def authorization_user (self , authorization_user : Optional [ str ]) -> None :
162
163
with self ._object_lock :
163
164
self ._authorization_user = authorization_user
164
165
165
166
@property
166
- def catalog (self ):
167
+ def catalog (self ) -> Optional [ str ] :
167
168
with self ._object_lock :
168
169
return self ._catalog
169
170
170
171
@catalog .setter
171
- def catalog (self , catalog ) :
172
+ def catalog (self , catalog : Optional [ str ]) -> None :
172
173
with self ._object_lock :
173
174
self ._catalog = catalog
174
175
175
176
@property
176
- def schema (self ):
177
+ def schema (self ) -> Optional [ str ] :
177
178
with self ._object_lock :
178
179
return self ._schema
179
180
180
181
@schema .setter
181
- def schema (self , schema ) :
182
+ def schema (self , schema : Optional [ str ]) -> None :
182
183
with self ._object_lock :
183
184
self ._schema = schema
184
185
185
186
@property
186
- def source (self ):
187
+ def source (self ) -> Optional [ str ] :
187
188
return self ._source
188
189
189
190
@property
190
- def properties (self ):
191
+ def properties (self ) -> Dict [ str , str ] :
191
192
with self ._object_lock :
192
193
return self ._properties
193
194
194
195
@properties .setter
195
- def properties (self , properties ) :
196
+ def properties (self , properties : Dict [ str , str ]) -> None :
196
197
with self ._object_lock :
197
198
self ._properties = properties
198
199
199
200
@property
200
- def headers (self ):
201
+ def headers (self ) -> Dict [ str , str ] :
201
202
return self ._headers
202
203
203
204
@property
204
- def transaction_id (self ):
205
+ def transaction_id (self ) -> Optional [ str ] :
205
206
with self ._object_lock :
206
207
return self ._transaction_id
207
208
208
209
@transaction_id .setter
209
- def transaction_id (self , transaction_id ) :
210
+ def transaction_id (self , transaction_id : Optional [ str ]) -> None :
210
211
with self ._object_lock :
211
212
self ._transaction_id = transaction_id
212
213
213
214
@property
214
- def extra_credential (self ):
215
+ def extra_credential (self ) -> Optional [ List [ Tuple [ str , str ]]] :
215
216
return self ._extra_credential
216
217
217
218
@property
218
- def client_tags (self ):
219
+ def client_tags (self ) -> List [ str ] :
219
220
return self ._client_tags
220
221
221
222
@property
222
- def roles (self ):
223
+ def roles (self ) -> Dict [ str , str ] :
223
224
with self ._object_lock :
224
225
return self ._roles
225
226
226
227
@roles .setter
227
- def roles (self , roles ) :
228
+ def roles (self , roles : Dict [ str , str ]) -> None :
228
229
with self ._object_lock :
229
230
self ._roles = roles
230
231
231
232
@property
232
- def prepared_statements (self ):
233
+ def prepared_statements (self ) -> Dict [ str , str ] :
233
234
return self ._prepared_statements
234
235
235
236
@prepared_statements .setter
236
- def prepared_statements (self , prepared_statements ) :
237
+ def prepared_statements (self , prepared_statements : Dict [ str , str ]) -> None :
237
238
with self ._object_lock :
238
239
self ._prepared_statements = prepared_statements
239
240
240
241
@property
241
- def timezone (self ):
242
+ def timezone (self ) -> str :
242
243
with self ._object_lock :
243
244
return self ._timezone
244
245
245
- def _format_roles (self , roles ):
246
+ @staticmethod
247
+ def _format_roles (roles : Union [Dict [str , str ], str ]) -> Dict [str , str ]:
246
248
if isinstance (roles , str ):
247
249
roles = {"system" : roles }
248
250
formatted_roles = {}
0 commit comments