Skip to content

Commit 79abffb

Browse files
committed
Add missing type annotations for the "ClientSession" class
1 parent bd511a4 commit 79abffb

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
@@ -112,18 +112,21 @@ class ClientSession:
112112
def __init__(
113113
self,
114114
user: str,
115-
authorization_user: str = None,
116-
catalog: str = None,
117-
schema: str = None,
118-
source: str = None,
119-
properties: Dict[str, str] = None,
120-
headers: Dict[str, str] = None,
121-
transaction_id: str = None,
122-
extra_credential: List[Tuple[str, str]] = None,
123-
client_tags: List[str] = None,
124-
roles: Union[Dict[str, str], str] = None,
125-
timezone: str = None,
115+
authorization_user: Optional[str] = None,
116+
catalog: Optional[str] = None,
117+
schema: Optional[str] = None,
118+
source: Optional[str] = None,
119+
properties: Optional[Dict[str, str]] = None,
120+
headers: Optional[Dict[str, str]] = None,
121+
transaction_id: Optional[str] = None,
122+
extra_credential: Optional[List[Tuple[str, str]]] = None,
123+
client_tags: Optional[List[str]] = None,
124+
roles: Optional[Union[Dict[str, str], str]] = None,
125+
timezone: Optional[str] = None,
126126
):
127+
self._object_lock = threading.Lock()
128+
self._prepared_statements: Dict[str, str] = {}
129+
127130
self._user = user
128131
self._authorization_user = authorization_user
129132
self._catalog = catalog
@@ -135,107 +138,106 @@ def __init__(
135138
self._extra_credential = extra_credential
136139
self._client_tags = client_tags.copy() if client_tags is not None else list()
137140
self._roles = self._format_roles(roles) if roles is not None else {}
138-
self._prepared_statements: Dict[str, str] = {}
139-
self._object_lock = threading.Lock()
140141
self._timezone = timezone or get_localzone_name()
141142
if timezone: # Check timezone validity
142143
ZoneInfo(timezone)
143144

144145
@property
145-
def user(self):
146+
def user(self) -> str:
146147
return self._user
147148

148149
@property
149-
def authorization_user(self):
150+
def authorization_user(self) -> Optional[str]:
150151
with self._object_lock:
151152
return self._authorization_user
152153

153154
@authorization_user.setter
154-
def authorization_user(self, authorization_user):
155+
def authorization_user(self, authorization_user: Optional[str]) -> None:
155156
with self._object_lock:
156157
self._authorization_user = authorization_user
157158

158159
@property
159-
def catalog(self):
160+
def catalog(self) -> Optional[str]:
160161
with self._object_lock:
161162
return self._catalog
162163

163164
@catalog.setter
164-
def catalog(self, catalog):
165+
def catalog(self, catalog: Optional[str]) -> None:
165166
with self._object_lock:
166167
self._catalog = catalog
167168

168169
@property
169-
def schema(self):
170+
def schema(self) -> Optional[str]:
170171
with self._object_lock:
171172
return self._schema
172173

173174
@schema.setter
174-
def schema(self, schema):
175+
def schema(self, schema: Optional[str]) -> None:
175176
with self._object_lock:
176177
self._schema = schema
177178

178179
@property
179-
def source(self):
180+
def source(self) -> Optional[str]:
180181
return self._source
181182

182183
@property
183-
def properties(self):
184+
def properties(self) -> Dict[str, str]:
184185
with self._object_lock:
185186
return self._properties
186187

187188
@properties.setter
188-
def properties(self, properties):
189+
def properties(self, properties: Dict[str, str]) -> None:
189190
with self._object_lock:
190191
self._properties = properties
191192

192193
@property
193-
def headers(self):
194+
def headers(self) -> Dict[str, str]:
194195
return self._headers
195196

196197
@property
197-
def transaction_id(self):
198+
def transaction_id(self) -> Optional[str]:
198199
with self._object_lock:
199200
return self._transaction_id
200201

201202
@transaction_id.setter
202-
def transaction_id(self, transaction_id):
203+
def transaction_id(self, transaction_id: Optional[str]) -> None:
203204
with self._object_lock:
204205
self._transaction_id = transaction_id
205206

206207
@property
207-
def extra_credential(self):
208+
def extra_credential(self) -> Optional[List[Tuple[str, str]]]:
208209
return self._extra_credential
209210

210211
@property
211-
def client_tags(self):
212+
def client_tags(self) -> List[str]:
212213
return self._client_tags
213214

214215
@property
215-
def roles(self):
216+
def roles(self) -> Dict[str, str]:
216217
with self._object_lock:
217218
return self._roles
218219

219220
@roles.setter
220-
def roles(self, roles):
221+
def roles(self, roles: Dict[str, str]) -> None:
221222
with self._object_lock:
222223
self._roles = roles
223224

224225
@property
225-
def prepared_statements(self):
226+
def prepared_statements(self) -> Dict[str, str]:
226227
return self._prepared_statements
227228

228229
@prepared_statements.setter
229-
def prepared_statements(self, prepared_statements):
230+
def prepared_statements(self, prepared_statements: Dict[str, str]) -> None:
230231
with self._object_lock:
231232
self._prepared_statements = prepared_statements
232233

233234
@property
234-
def timezone(self):
235+
def timezone(self) -> str:
235236
with self._object_lock:
236237
return self._timezone
237238

238-
def _format_roles(self, roles):
239+
@staticmethod
240+
def _format_roles(roles: Union[Dict[str, str], str]) -> Dict[str, str]:
239241
if isinstance(roles, str):
240242
roles = {"system": roles}
241243
formatted_roles = {}

0 commit comments

Comments
 (0)