77
88from atlassian_jwt_auth .exceptions import PublicKeyRetrieverException
99from atlassian_jwt_auth .key import PEM_FILE_TYPE
10- from atlassian_jwt_auth .key import \
11- HTTPSPublicKeyRetriever as _HTTPSPublicKeyRetriever
10+ from atlassian_jwt_auth .key import HTTPSPublicKeyRetriever as _HTTPSPublicKeyRetriever
1211
1312
1413class HTTPSPublicKeyRetriever (_HTTPSPublicKeyRetriever ):
1514 """A class for retrieving JWT public keys with aiohttp"""
15+
1616 _class_session = None
1717
18- def __init__ (self , base_url : str , * ,
19- loop : Optional [AbstractEventLoop ] = None ) -> None :
18+ def __init__ (
19+ self , base_url : str , * , loop : Optional [AbstractEventLoop ] = None
20+ ) -> None :
2021 if loop is None :
2122 loop = asyncio .get_event_loop ()
2223 self .loop = loop
@@ -25,34 +26,41 @@ def __init__(self, base_url: str, *,
2526 def _get_session (self ) -> aiohttp .ClientSession : # type: ignore[override]
2627 if HTTPSPublicKeyRetriever ._class_session is None :
2728 HTTPSPublicKeyRetriever ._class_session = aiohttp .ClientSession (
28- loop = self .loop )
29+ loop = self .loop
30+ )
2931 return HTTPSPublicKeyRetriever ._class_session
3032
3133 def _convert_proxies_to_proxy_arg (
32- self , url : str , requests_kwargs : Dict [Any , Any ]) -> Dict [str , Any ]:
33- """ returns a modified requests_kwargs dict that contains proxy
34- information in a form that aiohttp accepts
35- (it wants proxy information instead of a dict of proxies).
34+ self , url : str , requests_kwargs : Dict [Any , Any ]
35+ ) -> Dict [str , Any ]:
36+ """returns a modified requests_kwargs dict that contains proxy
37+ information in a form that aiohttp accepts
38+ (it wants proxy information instead of a dict of proxies).
3639 """
3740 proxy = None
38- if ' proxies' in requests_kwargs :
41+ if " proxies" in requests_kwargs :
3942 scheme = urllib .parse .urlparse (url ).scheme
40- proxy = requests_kwargs [' proxies' ].get (scheme , None )
41- del requests_kwargs [' proxies' ]
42- requests_kwargs [' proxy' ] = proxy
43+ proxy = requests_kwargs [" proxies" ].get (scheme , None )
44+ del requests_kwargs [" proxies" ]
45+ requests_kwargs [" proxy" ] = proxy
4346 return requests_kwargs
4447
4548 async def _retrieve (
46- self , url : str , requests_kwargs : Dict [Any , Any ]) -> Awaitable [ str ]:
47- requests_kwargs = self . _convert_proxies_to_proxy_arg (
48- url , requests_kwargs )
49+ self , url : str , requests_kwargs : Dict [Any , Any ]
50+ ) -> Awaitable [ str ]:
51+ requests_kwargs = self . _convert_proxies_to_proxy_arg ( url , requests_kwargs )
4952 try :
50- resp = await self ._session .get (url , headers = {'accept' : # type: ignore[misc]
51- PEM_FILE_TYPE },
52- ** requests_kwargs )
53+ resp = await self ._session .get (
54+ url ,
55+ headers = {
56+ "accept" : # type: ignore[misc]
57+ PEM_FILE_TYPE
58+ },
59+ ** requests_kwargs ,
60+ )
5361 resp .raise_for_status ()
54- self ._check_content_type (url , resp .headers [' content-type' ])
62+ self ._check_content_type (url , resp .headers [" content-type" ])
5563 return await resp .text ()
5664 except aiohttp .ClientError as e :
57- status_code = getattr (e , ' code' , None )
65+ status_code = getattr (e , " code" , None )
5866 raise PublicKeyRetrieverException (e , status_code = status_code )
0 commit comments