@@ -91,11 +91,11 @@ def test_case_name(request: FixtureRequest, target: str, config: str) -> str:
9191
9292
9393@pytest .fixture (scope = 'session' )
94- def pipeline_id (request : FixtureRequest ) -> t . Optional [ str ] :
94+ def pipeline_id (request : FixtureRequest ) -> str | None :
9595 return request .config .getoption ('pipeline_id' , None ) or os .getenv ('PARENT_PIPELINE_ID' , None ) # type: ignore
9696
9797
98- def get_pipeline_commit_sha_by_pipeline_id (pipeline_id : str ) -> t . Optional [ str ] :
98+ def get_pipeline_commit_sha_by_pipeline_id (pipeline_id : str ) -> str | None :
9999 gl = gitlab_api .Gitlab (os .getenv ('CI_PROJECT_ID' , 'espressif/esp-idf' ))
100100 pipeline = gl .project .pipelines .get (pipeline_id )
101101 if not pipeline :
@@ -120,12 +120,12 @@ class AppDownloader:
120120 def __init__ (
121121 self ,
122122 commit_sha : str ,
123- pipeline_id : t . Optional [ str ] = None ,
123+ pipeline_id : str | None = None ,
124124 ) -> None :
125125 self .commit_sha = commit_sha
126126 self .pipeline_id = pipeline_id
127127
128- def download_app (self , app_build_path : str , artifact_type : t . Optional [ str ] = None ) -> None :
128+ def download_app (self , app_build_path : str , artifact_type : str | None = None ) -> None :
129129 args = [
130130 'idf-ci' ,
131131 'gitlab' ,
@@ -155,9 +155,9 @@ def __init__(self, dut: 'IdfDut'):
155155 self .RETRY_DELAY = 1
156156 self .TELNET_PORT = 4444
157157 self .dut = dut
158- self .telnet : t . Optional [ Telnet ] = None
158+ self .telnet : Telnet | None = None
159159 self .log_file = os .path .join (self .dut .logdir , 'ocd.txt' )
160- self .proc : t . Optional [ pexpect .spawn ] = None
160+ self .proc : pexpect .spawn | None = None
161161
162162 def __enter__ (self ) -> 'OpenOCD' :
163163 return self
@@ -169,7 +169,7 @@ def run(self) -> t.Optional['OpenOCD']:
169169 desc_path = os .path .join (self .dut .app .binary_path , 'project_description.json' )
170170
171171 try :
172- with open (desc_path , 'r' ) as f :
172+ with open (desc_path ) as f :
173173 project_desc = json .load (f )
174174 except FileNotFoundError :
175175 logging .error ('Project description file not found at %s' , desc_path )
@@ -200,7 +200,7 @@ def run(self) -> t.Optional['OpenOCD']:
200200 if self .proc and self .proc .isalive ():
201201 self .proc .expect_exact ('Info : Listening on port 3333 for gdb connections' , timeout = 5 )
202202 self .connect_telnet ()
203- self .write ('log_output {}' . format ( self .log_file ) )
203+ self .write (f 'log_output { self .log_file } ' )
204204 return self
205205 except (pexpect .exceptions .EOF , pexpect .exceptions .TIMEOUT , ConnectionRefusedError ) as e :
206206 logging .error ('Error running OpenOCD: %s' , str (e ))
@@ -258,8 +258,8 @@ def openocd_dut(dut: IdfDut) -> OpenOCD:
258258
259259@pytest .fixture (scope = 'session' )
260260def app_downloader (
261- pipeline_id : t . Optional [ str ] ,
262- ) -> t . Optional [ AppDownloader ] :
261+ pipeline_id : str | None ,
262+ ) -> AppDownloader | None :
263263 if commit_sha := os .getenv ('PIPELINE_COMMIT_SHA' ):
264264 logging .debug ('pipeline commit sha from CI env is %s' , commit_sha )
265265 return AppDownloader (commit_sha , None )
@@ -283,9 +283,9 @@ def app_downloader(
283283def build_dir (
284284 request : FixtureRequest ,
285285 app_path : str ,
286- target : t . Optional [ str ] ,
287- config : t . Optional [ str ] ,
288- app_downloader : t . Optional [ AppDownloader ] ,
286+ target : str | None ,
287+ config : str | None ,
288+ app_downloader : AppDownloader | None ,
289289) -> str :
290290 """
291291 Check local build dir with the following priority:
@@ -561,10 +561,10 @@ def get_path(x: str) -> str:
561561
562562 if isinstance (_dut , list ):
563563 logs_files .extend ([template .format (get_path (d .logfile )) for d in _dut ])
564- dut_artifacts_url .append ('{}:' . format ( _dut [0 ].test_case_name ) )
564+ dut_artifacts_url .append (f' { _dut [0 ].test_case_name } :' )
565565 else :
566566 logs_files .append (template .format (get_path (_dut .logfile )))
567- dut_artifacts_url .append ('{}:' . format ( _dut .test_case_name ) )
567+ dut_artifacts_url .append (f' { _dut .test_case_name } :' )
568568
569569 for file in logs_files :
570570 dut_artifacts_url .append (' - {}' .format (quote (file , safe = ':/' )))
0 commit comments