8
8
import socket
9
9
import warnings
10
10
from asyncio import AbstractEventLoopPolicy
11
- from textwrap import dedent
12
- from typing import (
13
- Any ,
11
+ from collections .abc import (
14
12
AsyncIterator ,
15
13
Awaitable ,
16
- Callable ,
17
- Dict ,
18
14
Generator ,
19
15
Iterable ,
20
16
Iterator ,
21
- List ,
22
- Literal ,
23
17
Mapping ,
24
- Optional ,
25
18
Sequence ,
26
- Set ,
27
- Type ,
19
+ )
20
+ from textwrap import dedent
21
+ from typing import (
22
+ Any ,
23
+ Callable ,
24
+ Literal ,
25
+ Optional ,
28
26
TypeVar ,
29
27
Union ,
30
28
overload ,
@@ -215,7 +213,7 @@ def pytest_configure(config: Config) -> None:
215
213
216
214
217
215
@pytest .hookimpl (tryfirst = True )
218
- def pytest_report_header (config : Config ) -> List [str ]:
216
+ def pytest_report_header (config : Config ) -> list [str ]:
219
217
"""Add asyncio config to pytest header."""
220
218
mode = _get_asyncio_mode (config )
221
219
default_loop_scope = config .getini ("asyncio_default_fixture_loop_scope" )
@@ -224,7 +222,7 @@ def pytest_report_header(config: Config) -> List[str]:
224
222
225
223
def _preprocess_async_fixtures (
226
224
collector : Collector ,
227
- processed_fixturedefs : Set [FixtureDef ],
225
+ processed_fixturedefs : set [FixtureDef ],
228
226
) -> None :
229
227
config = collector .config
230
228
default_loop_scope = config .getini ("asyncio_default_fixture_loop_scope" )
@@ -279,10 +277,10 @@ def _synchronize_async_fixture(fixturedef: FixtureDef) -> None:
279
277
280
278
def _add_kwargs (
281
279
func : Callable [..., Any ],
282
- kwargs : Dict [str , Any ],
280
+ kwargs : dict [str , Any ],
283
281
event_loop : asyncio .AbstractEventLoop ,
284
282
request : FixtureRequest ,
285
- ) -> Dict [str , Any ]:
283
+ ) -> dict [str , Any ]:
286
284
sig = inspect .signature (func )
287
285
ret = kwargs .copy ()
288
286
if "request" in sig .parameters :
@@ -394,7 +392,7 @@ class PytestAsyncioFunction(Function):
394
392
@classmethod
395
393
def item_subclass_for (
396
394
cls , item : Function , /
397
- ) -> Union [Type ["PytestAsyncioFunction" ], None ]:
395
+ ) -> Union [type ["PytestAsyncioFunction" ], None ]:
398
396
"""
399
397
Returns a subclass of PytestAsyncioFunction if there is a specialized subclass
400
398
for the specified function item.
@@ -522,7 +520,7 @@ def runtest(self) -> None:
522
520
super ().runtest ()
523
521
524
522
525
- _HOLDER : Set [FixtureDef ] = set ()
523
+ _HOLDER : set [FixtureDef ] = set ()
526
524
527
525
528
526
# The function name needs to start with "pytest_"
@@ -531,7 +529,7 @@ def runtest(self) -> None:
531
529
def pytest_pycollect_makeitem_preprocess_async_fixtures (
532
530
collector : Union [pytest .Module , pytest .Class ], name : str , obj : object
533
531
) -> Union [
534
- pytest .Item , pytest .Collector , List [Union [pytest .Item , pytest .Collector ]], None
532
+ pytest .Item , pytest .Collector , list [Union [pytest .Item , pytest .Collector ]], None
535
533
]:
536
534
"""A pytest hook to collect asyncio coroutines."""
537
535
if not collector .funcnamefilter (name ):
@@ -555,7 +553,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
555
553
node_or_list_of_nodes : Union [
556
554
pytest .Item ,
557
555
pytest .Collector ,
558
- List [Union [pytest .Item , pytest .Collector ]],
556
+ list [Union [pytest .Item , pytest .Collector ]],
559
557
None ,
560
558
] = hook_result .get_result ()
561
559
except BaseException as e :
@@ -585,7 +583,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
585
583
586
584
587
585
_event_loop_fixture_id = StashKey [str ]()
588
- _fixture_scope_by_collector_type : Mapping [Type [pytest .Collector ], _ScopeName ] = {
586
+ _fixture_scope_by_collector_type : Mapping [type [pytest .Collector ], _ScopeName ] = {
589
587
Class : "class" ,
590
588
# Package is a subclass of module and the dict is used in isinstance checks
591
589
# Therefore, the order matters and Package needs to appear before Module
@@ -596,7 +594,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
596
594
597
595
# A stack used to push package-scoped loops during collection of a package
598
596
# and pop those loops during collection of a Module
599
- __package_loop_stack : List [Union [FixtureFunctionMarker , FixtureFunction ]] = []
597
+ __package_loop_stack : list [Union [FixtureFunctionMarker , FixtureFunction ]] = []
600
598
601
599
602
600
@pytest .hookimpl
0 commit comments