16
16
from __future__ import annotations
17
17
18
18
import asyncio
19
+ import threading
19
20
import time
20
21
from dataclasses import dataclass , field
21
22
from typing import TYPE_CHECKING , Any , Mapping , MutableMapping , Optional , Union
@@ -82,7 +83,11 @@ class _OIDCAuthenticator:
82
83
access_token : Optional [str ] = field (default = None )
83
84
idp_info : Optional [OIDCIdPInfo ] = field (default = None )
84
85
token_gen_id : int = field (default = 0 )
85
- lock : Lock = field (default_factory = _async_create_lock )
86
+ if not _IS_SYNC :
87
+ lock : Lock = field (default_factory = _async_create_lock ) # type: ignore[assignment]
88
+ else :
89
+ lock : threading .Lock = field (default_factory = _async_create_lock ) # type: ignore[assignment, no-redef]
90
+
86
91
last_call_time : float = field (default = 0 )
87
92
88
93
async def reauthenticate (self , conn : AsyncConnection ) -> Optional [Mapping [str , Any ]]:
@@ -187,7 +192,7 @@ async def _get_access_token(self) -> Optional[str]:
187
192
return None
188
193
189
194
if not prev_token and cb is not None :
190
- async with self .lock :
195
+ async with self .lock : # type: ignore[attr-defined]
191
196
# See if the token was changed while we were waiting for the
192
197
# lock.
193
198
new_token = self .access_token
@@ -213,7 +218,7 @@ async def _get_access_token(self) -> Optional[str]:
213
218
username = self .properties .username ,
214
219
)
215
220
if not _IS_SYNC :
216
- resp = await asyncio .get_running_loop ().run_in_executor (None , cb .fetch , context )
221
+ resp = await asyncio .get_running_loop ().run_in_executor (None , cb .fetch , context ) # type: ignore[assignment]
217
222
else :
218
223
resp = cb .fetch (context )
219
224
if not isinstance (resp , OIDCCallbackResult ):
0 commit comments