1616from __future__ import annotations
1717
1818import asyncio
19+ import threading
1920import time
2021from dataclasses import dataclass , field
2122from typing import TYPE_CHECKING , Any , Mapping , MutableMapping , Optional , Union
@@ -82,7 +83,11 @@ class _OIDCAuthenticator:
8283 access_token : Optional [str ] = field (default = None )
8384 idp_info : Optional [OIDCIdPInfo ] = field (default = None )
8485 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+
8691 last_call_time : float = field (default = 0 )
8792
8893 async def reauthenticate (self , conn : AsyncConnection ) -> Optional [Mapping [str , Any ]]:
@@ -187,7 +192,7 @@ async def _get_access_token(self) -> Optional[str]:
187192 return None
188193
189194 if not prev_token and cb is not None :
190- async with self .lock :
195+ async with self .lock : # type: ignore[attr-defined]
191196 # See if the token was changed while we were waiting for the
192197 # lock.
193198 new_token = self .access_token
@@ -213,7 +218,7 @@ async def _get_access_token(self) -> Optional[str]:
213218 username = self .properties .username ,
214219 )
215220 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]
217222 else :
218223 resp = cb .fetch (context )
219224 if not isinstance (resp , OIDCCallbackResult ):
0 commit comments