88import socket
99import warnings
1010from asyncio import AbstractEventLoopPolicy
11- from textwrap import dedent
12- from typing import (
13- Any ,
11+ from collections .abc import (
1412 AsyncIterator ,
1513 Awaitable ,
16- Callable ,
17- Dict ,
1814 Generator ,
1915 Iterable ,
2016 Iterator ,
21- List ,
22- Literal ,
2317 Mapping ,
24- Optional ,
2518 Sequence ,
26- Set ,
27- Type ,
19+ )
20+ from textwrap import dedent
21+ from typing import (
22+ Any ,
23+ Callable ,
24+ Literal ,
25+ Optional ,
2826 TypeVar ,
2927 Union ,
3028 overload ,
@@ -215,7 +213,7 @@ def pytest_configure(config: Config) -> None:
215213
216214
217215@pytest .hookimpl (tryfirst = True )
218- def pytest_report_header (config : Config ) -> List [str ]:
216+ def pytest_report_header (config : Config ) -> list [str ]:
219217 """Add asyncio config to pytest header."""
220218 mode = _get_asyncio_mode (config )
221219 default_loop_scope = config .getini ("asyncio_default_fixture_loop_scope" )
@@ -224,7 +222,7 @@ def pytest_report_header(config: Config) -> List[str]:
224222
225223def _preprocess_async_fixtures (
226224 collector : Collector ,
227- processed_fixturedefs : Set [FixtureDef ],
225+ processed_fixturedefs : set [FixtureDef ],
228226) -> None :
229227 config = collector .config
230228 default_loop_scope = config .getini ("asyncio_default_fixture_loop_scope" )
@@ -279,10 +277,10 @@ def _synchronize_async_fixture(fixturedef: FixtureDef) -> None:
279277
280278def _add_kwargs (
281279 func : Callable [..., Any ],
282- kwargs : Dict [str , Any ],
280+ kwargs : dict [str , Any ],
283281 event_loop : asyncio .AbstractEventLoop ,
284282 request : FixtureRequest ,
285- ) -> Dict [str , Any ]:
283+ ) -> dict [str , Any ]:
286284 sig = inspect .signature (func )
287285 ret = kwargs .copy ()
288286 if "request" in sig .parameters :
@@ -394,7 +392,7 @@ class PytestAsyncioFunction(Function):
394392 @classmethod
395393 def item_subclass_for (
396394 cls , item : Function , /
397- ) -> Union [Type ["PytestAsyncioFunction" ], None ]:
395+ ) -> Union [type ["PytestAsyncioFunction" ], None ]:
398396 """
399397 Returns a subclass of PytestAsyncioFunction if there is a specialized subclass
400398 for the specified function item.
@@ -522,7 +520,7 @@ def runtest(self) -> None:
522520 super ().runtest ()
523521
524522
525- _HOLDER : Set [FixtureDef ] = set ()
523+ _HOLDER : set [FixtureDef ] = set ()
526524
527525
528526# The function name needs to start with "pytest_"
@@ -531,7 +529,7 @@ def runtest(self) -> None:
531529def pytest_pycollect_makeitem_preprocess_async_fixtures (
532530 collector : Union [pytest .Module , pytest .Class ], name : str , obj : object
533531) -> 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
535533]:
536534 """A pytest hook to collect asyncio coroutines."""
537535 if not collector .funcnamefilter (name ):
@@ -555,7 +553,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
555553 node_or_list_of_nodes : Union [
556554 pytest .Item ,
557555 pytest .Collector ,
558- List [Union [pytest .Item , pytest .Collector ]],
556+ list [Union [pytest .Item , pytest .Collector ]],
559557 None ,
560558 ] = hook_result .get_result ()
561559 except BaseException as e :
@@ -585,7 +583,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
585583
586584
587585_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 ] = {
589587 Class : "class" ,
590588 # Package is a subclass of module and the dict is used in isinstance checks
591589 # Therefore, the order matters and Package needs to appear before Module
@@ -596,7 +594,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
596594
597595# A stack used to push package-scoped loops during collection of a package
598596# 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 ]] = []
600598
601599
602600@pytest .hookimpl
0 commit comments