1+ from __future__ import annotations
2+
13import itertools
24import json
3- from typing import List , Tuple , Union
5+ from typing import Iterator , Tuple , Union
46
57import pytest
68from botocore .exceptions import ReadTimeoutError
911from aiobotocore import utils
1012from aiobotocore ._helpers import asynccontextmanager
1113
14+ # TypeAlias (requires typing_extensions or >=3.10 to annotate)
15+ Response = Tuple [Union [str , object ], int ]
16+
1217
1318# From class TestContainerMetadataFetcher
14- def fake_aiohttp_session (
15- responses : Union [
16- List [Tuple [Union [str , object ], int ]], Tuple [Union [str , object ], int ]
17- ]
18- ):
19+ def fake_aiohttp_session (responses : list [Response ] | Response ):
1920 """
2021 Dodgy shim class
2122 """
22- if isinstance (responses , Tuple ):
23- data = itertools .cycle ([responses ])
23+ if isinstance (responses , tuple ):
24+ data : Iterator [ Response ] = itertools .cycle ([responses ])
2425 else :
2526 data = iter (responses )
2627
@@ -83,9 +84,7 @@ async def test_idmsfetcher_disabled():
8384@pytest .mark .asyncio
8485async def test_idmsfetcher_get_token_success ():
8586 session = fake_aiohttp_session (
86- [
87- ('blah' , 200 ),
88- ]
87+ ('blah' , 200 ),
8988 )
9089
9190 fetcher = utils .AioIMDSFetcher (
@@ -99,9 +98,7 @@ async def test_idmsfetcher_get_token_success():
9998@pytest .mark .asyncio
10099async def test_idmsfetcher_get_token_not_found ():
101100 session = fake_aiohttp_session (
102- [
103- ('blah' , 404 ),
104- ]
101+ ('blah' , 404 ),
105102 )
106103
107104 fetcher = utils .AioIMDSFetcher (
@@ -115,9 +112,7 @@ async def test_idmsfetcher_get_token_not_found():
115112@pytest .mark .asyncio
116113async def test_idmsfetcher_get_token_bad_request ():
117114 session = fake_aiohttp_session (
118- [
119- ('blah' , 400 ),
120- ]
115+ ('blah' , 400 ),
121116 )
122117
123118 fetcher = utils .AioIMDSFetcher (
0 commit comments