55import os
66import time
77import traceback
8+ from collections .abc import Iterator
89from io import StringIO
910from pathlib import Path
10- from typing import (
11- TYPE_CHECKING ,
12- Any ,
13- Dict ,
14- Iterator ,
15- List ,
16- Optional ,
17- Protocol ,
18- Set ,
19- Tuple ,
20- Union ,
21- cast ,
22- )
11+ from typing import TYPE_CHECKING , Any , Optional , Protocol , Union , cast
2312from urllib .parse import urljoin
2413
2514import pytest
26- from cwltest .compare import CompareFail , compare
2715
2816from cwltest import REQUIRED , UNSUPPORTED_FEATURE , logger , utils
17+ from cwltest .compare import CompareFail , compare
2918
3019if TYPE_CHECKING :
3120 from _pytest ._code .code import ExceptionInfo , TracebackStyle
@@ -42,12 +31,12 @@ class TestRunner(Protocol):
4231
4332 def __call__ (
4433 self , config : utils .CWLTestConfig , processfile : str , jobfile : Optional [str ]
45- ) -> List [Optional [Dict [str , Any ]]]:
34+ ) -> list [Optional [dict [str , Any ]]]:
4635 """Type signature for pytest_cwl_execute_test hook results."""
4736 ...
4837
4938
50- def _get_comma_separated_option (config : "Config" , name : str ) -> List [str ]:
39+ def _get_comma_separated_option (config : "Config" , name : str ) -> list [str ]:
5140 options = config .getoption (name )
5241 if options is None :
5342 return []
@@ -58,7 +47,7 @@ def _get_comma_separated_option(config: "Config", name: str) -> List[str]:
5847
5948
6049def _run_test_hook_or_plain (
61- test : Dict [str , str ],
50+ test : dict [str , str ],
6251 config : utils .CWLTestConfig ,
6352 hook : "HookCaller" ,
6453) -> utils .TestResult :
@@ -76,7 +65,7 @@ def _run_test_hook_or_plain(
7665 hook_out = hook (config = config , processfile = processfile , jobfile = jobfile )
7766 if not hook_out :
7867 return utils .run_test_plain (config , test )
79- returncode , out = cast (Tuple [int , Optional [Dict [str , Any ]]], hook_out [0 ])
68+ returncode , out = cast (tuple [int , Optional [dict [str , Any ]]], hook_out [0 ])
8069 duration = time .time () - start_time
8170 outstr = json .dumps (out ) if out is not None else "{}"
8271 if returncode == UNSUPPORTED_FEATURE :
@@ -164,7 +153,7 @@ def __init__(
164153 self ,
165154 name : str ,
166155 parent : Optional ["Node" ],
167- spec : Dict [str , Any ],
156+ spec : dict [str , Any ],
168157 ) -> None :
169158 """Initialize this CWLItem."""
170159 super ().__init__ (name , parent )
@@ -198,7 +187,7 @@ def runtest(self) -> None:
198187 hook ,
199188 )
200189 cwl_results = self .config .cwl_results # type: ignore[attr-defined]
201- cast (List [ Tuple [ Dict [str , Any ], utils .TestResult ]], cwl_results ).append (
190+ cast (list [ tuple [ dict [str , Any ], utils .TestResult ]], cwl_results ).append (
202191 (self .spec , result )
203192 )
204193 if result .return_code != 0 :
@@ -238,7 +227,7 @@ def repr_failure(
238227 )
239228 )
240229
241- def reportinfo (self ) -> Tuple [Union ["os.PathLike[str]" , str ], Optional [int ], str ]:
230+ def reportinfo (self ) -> tuple [Union ["os.PathLike[str]" , str ], Optional [int ], str ]:
242231 """Status report."""
243232 return self .path , 0 , "cwl test: %s" % self .name
244233
@@ -258,10 +247,10 @@ def _add_global_properties(self) -> None:
258247
259248 def collect (self ) -> Iterator [CWLItem ]:
260249 """Load the cwltest file and yield parsed entries."""
261- include : Set [str ] = set (_get_comma_separated_option (self .config , "cwl_include" ))
262- exclude : Set [str ] = set (_get_comma_separated_option (self .config , "cwl_exclude" ))
263- tags : Set [str ] = set (_get_comma_separated_option (self .config , "cwl_tags" ))
264- exclude_tags : Set [str ] = set (
250+ include : set [str ] = set (_get_comma_separated_option (self .config , "cwl_include" ))
251+ exclude : set [str ] = set (_get_comma_separated_option (self .config , "cwl_exclude" ))
252+ tags : set [str ] = set (_get_comma_separated_option (self .config , "cwl_tags" ))
253+ exclude_tags : set [str ] = set (
265254 _get_comma_separated_option (self .config , "cwl_exclude_tags" )
266255 )
267256 tests , _ = utils .load_and_validate_tests (str (self .path ))
@@ -302,7 +291,7 @@ def collect(self) -> Iterator[CWLItem]:
302291 yield item
303292
304293
305- __OPTIONS : List [ Tuple [str , Dict [str , Any ]]] = [
294+ __OPTIONS : list [ tuple [str , dict [str , Any ]]] = [
306295 (
307296 "--cwl-runner" ,
308297 {
@@ -400,14 +389,14 @@ def pytest_collect_file(
400389
401390def pytest_configure (config : "PytestConfig" ) -> None :
402391 """Store the raw tests and the test results."""
403- cwl_results : List [ Tuple [ Dict [str , Any ], utils .TestResult ]] = []
392+ cwl_results : list [ tuple [ dict [str , Any ], utils .TestResult ]] = []
404393 config .cwl_results = cwl_results # type: ignore[attr-defined]
405394
406395
407396def pytest_sessionfinish (session : pytest .Session , exitstatus : int ) -> None :
408397 """Generate badges."""
409398 cwl_results = cast (
410- List [ Tuple [ Dict [str , Any ], utils .TestResult ]],
399+ list [ tuple [ dict [str , Any ], utils .TestResult ]],
411400 getattr (session .config , "cwl_results" , None ),
412401 )
413402 if not cwl_results :
0 commit comments