|
29 | 29 | from urllib.parse import ParseResult, parse_qs, unquote, urlparse |
30 | 30 |
|
31 | 31 | from ..auth.token import TokenInterface |
32 | | -from ..event import EventDispatcher, AsyncAfterConnectionReleasedEvent |
| 32 | +from ..event import AsyncAfterConnectionReleasedEvent, EventDispatcher |
33 | 33 | from ..utils import format_error_message |
34 | 34 |
|
35 | 35 | # the functionality is available in 3.11.x but has a major issue before |
|
42 | 42 | from redis.asyncio.retry import Retry |
43 | 43 | from redis.backoff import NoBackoff |
44 | 44 | from redis.connection import DEFAULT_RESP_VERSION |
45 | | -from redis.credentials import CredentialProvider, UsernamePasswordCredentialProvider, StreamingCredentialProvider |
| 45 | +from redis.credentials import ( |
| 46 | + CredentialProvider, |
| 47 | + StreamingCredentialProvider, |
| 48 | + UsernamePasswordCredentialProvider, |
| 49 | +) |
46 | 50 | from redis.exceptions import ( |
47 | 51 | AuthenticationError, |
48 | 52 | AuthenticationWrongNumberOfArgsError, |
@@ -151,7 +155,7 @@ def __init__( |
151 | 155 | encoder_class: Type[Encoder] = Encoder, |
152 | 156 | credential_provider: Optional[CredentialProvider] = None, |
153 | 157 | protocol: Optional[int] = 2, |
154 | | - event_dispatcher: Optional[EventDispatcher] = EventDispatcher() |
| 158 | + event_dispatcher: Optional[EventDispatcher] = EventDispatcher(), |
155 | 159 | ): |
156 | 160 | if (username or password) and credential_provider is not None: |
157 | 161 | raise DataError( |
@@ -678,9 +682,9 @@ def set_re_auth_token(self, token: TokenInterface): |
678 | 682 | async def re_auth(self): |
679 | 683 | if self._re_auth_token is not None: |
680 | 684 | await self.send_command( |
681 | | - 'AUTH', |
682 | | - self._re_auth_token.try_get('oid'), |
683 | | - self._re_auth_token.get_value() |
| 685 | + "AUTH", |
| 686 | + self._re_auth_token.try_get("oid"), |
| 687 | + self._re_auth_token.get_value(), |
684 | 688 | ) |
685 | 689 | await self.read_response() |
686 | 690 | self._re_auth_token = None |
@@ -1143,7 +1147,9 @@ async def release(self, connection: AbstractConnection): |
1143 | 1147 | # not doing so is an error that will cause an exception here. |
1144 | 1148 | self._in_use_connections.remove(connection) |
1145 | 1149 | self._available_connections.append(connection) |
1146 | | - await self._event_dispatcher.dispatch_async(AsyncAfterConnectionReleasedEvent(connection)) |
| 1150 | + await self._event_dispatcher.dispatch_async( |
| 1151 | + AsyncAfterConnectionReleasedEvent(connection) |
| 1152 | + ) |
1147 | 1153 |
|
1148 | 1154 | async def disconnect(self, inuse_connections: bool = True): |
1149 | 1155 | """ |
@@ -1181,12 +1187,13 @@ async def re_auth_callback(self, token: TokenInterface): |
1181 | 1187 | async with self._lock: |
1182 | 1188 | for conn in self._available_connections: |
1183 | 1189 | await conn.retry.call_with_retry( |
1184 | | - lambda: conn.send_command('AUTH', token.try_get('oid'), token.get_value()), |
1185 | | - lambda error: self._mock(error) |
| 1190 | + lambda: conn.send_command( |
| 1191 | + "AUTH", token.try_get("oid"), token.get_value() |
| 1192 | + ), |
| 1193 | + lambda error: self._mock(error), |
1186 | 1194 | ) |
1187 | 1195 | await conn.retry.call_with_retry( |
1188 | | - lambda: conn.read_response(), |
1189 | | - lambda error: self._mock(error) |
| 1196 | + lambda: conn.read_response(), lambda error: self._mock(error) |
1190 | 1197 | ) |
1191 | 1198 | for conn in self._in_use_connections: |
1192 | 1199 | conn.set_re_auth_token(token) |
|
0 commit comments