Skip to content

Commit 208880f

Browse files
arturdryomovhashhar
authored andcommitted
Add missing type annotations for the "ClientSession" class
1 parent 58f8164 commit 208880f

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

trino/client.py

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,21 @@ class ClientSession:
119119
def __init__(
120120
self,
121121
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,
133133
):
134+
self._object_lock = threading.Lock()
135+
self._prepared_statements: Dict[str, str] = {}
136+
134137
self._user = user
135138
self._authorization_user = authorization_user
136139
self._catalog = catalog
@@ -142,107 +145,106 @@ def __init__(
142145
self._extra_credential = extra_credential
143146
self._client_tags = client_tags.copy() if client_tags is not None else list()
144147
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()
147148
self._timezone = timezone or get_localzone_name()
148149
if timezone: # Check timezone validity
149150
ZoneInfo(timezone)
150151

151152
@property
152-
def user(self):
153+
def user(self) -> str:
153154
return self._user
154155

155156
@property
156-
def authorization_user(self):
157+
def authorization_user(self) -> Optional[str]:
157158
with self._object_lock:
158159
return self._authorization_user
159160

160161
@authorization_user.setter
161-
def authorization_user(self, authorization_user):
162+
def authorization_user(self, authorization_user: Optional[str]) -> None:
162163
with self._object_lock:
163164
self._authorization_user = authorization_user
164165

165166
@property
166-
def catalog(self):
167+
def catalog(self) -> Optional[str]:
167168
with self._object_lock:
168169
return self._catalog
169170

170171
@catalog.setter
171-
def catalog(self, catalog):
172+
def catalog(self, catalog: Optional[str]) -> None:
172173
with self._object_lock:
173174
self._catalog = catalog
174175

175176
@property
176-
def schema(self):
177+
def schema(self) -> Optional[str]:
177178
with self._object_lock:
178179
return self._schema
179180

180181
@schema.setter
181-
def schema(self, schema):
182+
def schema(self, schema: Optional[str]) -> None:
182183
with self._object_lock:
183184
self._schema = schema
184185

185186
@property
186-
def source(self):
187+
def source(self) -> Optional[str]:
187188
return self._source
188189

189190
@property
190-
def properties(self):
191+
def properties(self) -> Dict[str, str]:
191192
with self._object_lock:
192193
return self._properties
193194

194195
@properties.setter
195-
def properties(self, properties):
196+
def properties(self, properties: Dict[str, str]) -> None:
196197
with self._object_lock:
197198
self._properties = properties
198199

199200
@property
200-
def headers(self):
201+
def headers(self) -> Dict[str, str]:
201202
return self._headers
202203

203204
@property
204-
def transaction_id(self):
205+
def transaction_id(self) -> Optional[str]:
205206
with self._object_lock:
206207
return self._transaction_id
207208

208209
@transaction_id.setter
209-
def transaction_id(self, transaction_id):
210+
def transaction_id(self, transaction_id: Optional[str]) -> None:
210211
with self._object_lock:
211212
self._transaction_id = transaction_id
212213

213214
@property
214-
def extra_credential(self):
215+
def extra_credential(self) -> Optional[List[Tuple[str, str]]]:
215216
return self._extra_credential
216217

217218
@property
218-
def client_tags(self):
219+
def client_tags(self) -> List[str]:
219220
return self._client_tags
220221

221222
@property
222-
def roles(self):
223+
def roles(self) -> Dict[str, str]:
223224
with self._object_lock:
224225
return self._roles
225226

226227
@roles.setter
227-
def roles(self, roles):
228+
def roles(self, roles: Dict[str, str]) -> None:
228229
with self._object_lock:
229230
self._roles = roles
230231

231232
@property
232-
def prepared_statements(self):
233+
def prepared_statements(self) -> Dict[str, str]:
233234
return self._prepared_statements
234235

235236
@prepared_statements.setter
236-
def prepared_statements(self, prepared_statements):
237+
def prepared_statements(self, prepared_statements: Dict[str, str]) -> None:
237238
with self._object_lock:
238239
self._prepared_statements = prepared_statements
239240

240241
@property
241-
def timezone(self):
242+
def timezone(self) -> str:
242243
with self._object_lock:
243244
return self._timezone
244245

245-
def _format_roles(self, roles):
246+
@staticmethod
247+
def _format_roles(roles: Union[Dict[str, str], str]) -> Dict[str, str]:
246248
if isinstance(roles, str):
247249
roles = {"system": roles}
248250
formatted_roles = {}

0 commit comments

Comments
 (0)