2121from monitoring .uss_qualifier .reports .sequence_view .summary_types import (
2222 ActionNode ,
2323 ActionNodeType ,
24- EpochType ,
25- EventType ,
2624 Indexer ,
2725 TestedCase ,
2826 TestedScenario ,
@@ -110,6 +108,7 @@ def generate_globally_expanded_report(
110108
111109"""
112110
111+ assert report .configuration .v1 and report .configuration .v1 .test_run
113112 resource_pool = make_resources_config (report .configuration .v1 .test_run )
114113
115114 def indented_ul (value ) -> list [str ]:
@@ -184,6 +183,7 @@ def describe_pool_resource(k: str, v: dict) -> str:
184183
185184def _generate_sections (node : ActionNode ) -> Iterator [_Section ]:
186185 if node .node_type == ActionNodeType .Scenario :
186+ assert node .scenario
187187 yield _generate_scenario_section (node .scenario )
188188 elif node .node_type == ActionNodeType .SkippedAction :
189189 yield _generate_skipped_scenario_section (node )
@@ -195,7 +195,7 @@ def _generate_sections(node: ActionNode) -> Iterator[_Section]:
195195def _generate_skipped_scenario_section (node : ActionNode ) -> _Section :
196196 return _Section (
197197 title = f"[skipped] { node .name } " ,
198- body = f"This instance of this test scenario was skipped in this test run because: { node .skipped_action .reason } " ,
198+ body = f"This instance of this test scenario was skipped in this test run because: { node .skipped_action .reason if node . skipped_action else '?' } " ,
199199 )
200200
201201
@@ -237,15 +237,15 @@ def _indent_headings(elements: Sequence[marko.element.Element], levels: int) ->
237237 for element in elements :
238238 if isinstance (element , marko .block .Heading ):
239239 element .level = min (element .level + levels , 6 )
240- if hasattr (element , "children" ) and element .children :
241- _indent_headings (element .children , levels )
240+ if hasattr (element , "children" ) and element .children : # pyright: ignore[reportAttributeAccessIssue]
241+ _indent_headings (element .children , levels ) # pyright: ignore[reportAttributeAccessIssue]
242242
243243
244244def _inflate_fragments (parent : marko .element .Element , origin_filename : str ) -> None :
245- if hasattr (parent , "children" ) and parent .children :
245+ if hasattr (parent , "children" ) and parent .children : # pyright: ignore[reportAttributeAccessIssue]
246246 c = 0
247- while c < len (parent .children ):
248- child = parent .children [c ]
247+ while c < len (parent .children ): # pyright: ignore[reportAttributeAccessIssue]
248+ child = parent .children [c ] # pyright: ignore[reportAttributeAccessIssue]
249249 if (
250250 isinstance (child , marko .block .Heading )
251251 and hasattr (child , "children" )
@@ -260,12 +260,12 @@ def _inflate_fragments(parent: marko.element.Element, origin_filename: str) -> N
260260 doc = _get_test_step_fragment (absolute_path , child .level )
261261 _update_links (doc , absolute_path )
262262 _strip_link (child )
263- parent .children = (
264- parent .children [0 : c + 1 ] + doc .children + parent .children [c + 1 :]
263+ parent .children = ( # pyright: ignore[reportAttributeAccessIssue]
264+ parent .children [0 : c + 1 ] + doc .children + parent .children [c + 1 :] # pyright: ignore[reportAttributeAccessIssue]
265265 )
266266 c += len (doc .children )
267267 elif isinstance (child , marko .element .Element ):
268- _inflate_fragments (parent .children [c ], origin_filename )
268+ _inflate_fragments (parent .children [c ], origin_filename ) # pyright: ignore[reportAttributeAccessIssue]
269269 c += 1
270270 else :
271271 c += 1
@@ -286,14 +286,14 @@ def add_resource_origin():
286286 note = marko .parse (
287287 """∅ _This resource was not applicable to this test run and was therefore not provided._\n \n """
288288 )
289- doc .children = doc .children [0 :c ] + note .children + doc .children [c :]
289+ doc .children = doc .children [0 :c ] + note .children + doc .children [c :] # pyright: ignore[reportAttributeAccessIssue,reportOperatorIssue]
290290 c += len (note .children )
291291 return
292292 # Insert resource origin information
293293 origin = marko .parse (
294294 f"\n \n ✅ Provided by { scenario .resource_origins [current_resource ]} .\n "
295295 )
296- doc .children = doc .children [0 :c ] + origin .children + doc .children [c :]
296+ doc .children = doc .children [0 :c ] + origin .children + doc .children [c :] # pyright: ignore[reportOperatorIssue]
297297 c += len (origin .children )
298298
299299 while c < len (doc .children ):
@@ -327,11 +327,11 @@ def add_resource_origin():
327327
328328
329329def _strip_link (element : marko .element .Element ) -> None :
330- if hasattr (element , "children" ) and element .children :
331- for c in range (len (element .children )):
332- child = element .children [c ]
330+ if hasattr (element , "children" ) and element .children : # pyright: ignore[reportAttributeAccessIssue]
331+ for c in range (len (element .children )): # pyright: ignore[reportAttributeAccessIssue]
332+ child = element .children [c ] # pyright: ignore[reportAttributeAccessIssue]
333333 if isinstance (child , marko .block .inline .Link ):
334- element .children [c ] = child .children [0 ]
334+ element .children [c ] = child .children [0 ] # pyright: ignore[reportAttributeAccessIssue]
335335 elif isinstance (child , marko .element .Element ):
336336 _strip_link (child )
337337
@@ -372,7 +372,7 @@ def add_context_to_case():
372372 """∅ _This test case was not applicable to this test run and is therefore not statused._\n \n """
373373 )
374374 doc .children = (
375- doc .children [0 : test_case_i0 + 1 ]
375+ doc .children [0 : test_case_i0 + 1 ] # pyright: ignore[reportAttributeAccessIssue,reportOperatorIssue]
376376 + note .children
377377 + doc .children [test_case_i0 + 1 :]
378378 )
@@ -394,7 +394,7 @@ def add_context_to_case():
394394 test_case_i0 = c
395395 test_case_level = child .level
396396 for epoch in scenario .epochs :
397- if epoch .type != EpochType . Case :
397+ if epoch .case is None :
398398 continue
399399 if case_name == epoch .case .name :
400400 test_case = epoch .case
@@ -407,7 +407,7 @@ def add_context_to_case():
407407 test_case_level = child .level
408408 cleanup = True
409409 for epoch in scenario .epochs :
410- if epoch .type != EpochType . Case :
410+ if epoch .case is None :
411411 continue
412412 if len (epoch .case .steps ) == 1 and epoch .case .steps [0 ].name == "Cleanup" :
413413 test_case = epoch .case
@@ -444,7 +444,7 @@ def add_context_to_step():
444444 )
445445 dc = len (note .children )
446446 doc .children = (
447- doc .children [0 : test_step_i0 + 1 ]
447+ doc .children [0 : test_step_i0 + 1 ] # pyright: ignore[reportOperatorIssue]
448448 + note .children
449449 + doc .children [test_step_i0 + 1 :]
450450 )
@@ -494,6 +494,7 @@ def _add_context_to_step(
494494 def add_context_to_check ():
495495 nonlocal c , i1 , added , test_check_name , test_check_i0 , test_check_level
496496 if test_check_name is not None :
497+ assert test_check_i0 is not None
497498 dc = _add_context_to_check (doc , step , test_check_name , test_check_i0 , c )
498499 c += dc
499500 i1 += dc
@@ -533,14 +534,14 @@ def _add_context_to_check(
533534 check_text = ["" ]
534535 for event in step .events :
535536 if (
536- event .type == EventType . PassedCheck
537+ event .passed_check is not None
537538 and event .passed_check .name == test_check_name
538539 ):
539540 check_text .append (
540541 f"✅ { ', ' .join (event .passed_check .participants )} ({ event .passed_check .timestamp } )"
541542 )
542543 elif (
543- event .type == EventType . FailedCheck
544+ event .failed_check is not None
544545 and event .failed_check .name == test_check_name
545546 ):
546547 check_text .append (
@@ -552,7 +553,7 @@ def _add_context_to_check(
552553 additions = marko .parse (
553554 """∅ _This check was not applicable to this test run and is therefore not statused._\n \n """
554555 )
555- doc .children = doc .children [0 :i1 ] + additions .children + doc .children [i1 :]
556+ doc .children = doc .children [0 :i1 ] + additions .children + doc .children [i1 :] # pyright: ignore[reportOperatorIssue]
556557 return len (additions .children )
557558
558559
@@ -571,16 +572,16 @@ def _update_links(element: marko.element.Element, origin_filename: str) -> None:
571572 url = url .replace ("/github.com/" , "/raw.githubusercontent.com/" )
572573 url = url .replace ("/blob/" , "/" )
573574 element .dest = url
574- if hasattr (element , "children" ) and element .children :
575- for child in element .children :
575+ if hasattr (element , "children" ) and element .children : # pyright: ignore[reportAttributeAccessIssue]
576+ for child in element .children : # pyright: ignore[reportAttributeAccessIssue]
576577 if isinstance (child , marko .element .Element ):
577578 _update_links (child , origin_filename )
578579
579580
580581def _add_section_numbers (elements : Sequence [marko .element .Element ]) -> None :
581582 heading_level = 2
582583 levels = [0 ]
583- headings = [None ]
584+ headings : list [ str | None ] = [None ]
584585 prev_heading = None
585586 for i , element in enumerate (elements ):
586587 if isinstance (element , marko .block .Heading ):
@@ -599,7 +600,7 @@ def _add_section_numbers(elements: Sequence[marko.element.Element]) -> None:
599600 heading_level += 1
600601 else :
601602 headings .append (text_of (element ))
602- heading_trace = " -> " .join (headings )
603+ heading_trace = " -> " .join ([ str ( heading ) for heading in headings ] )
603604 raise ValueError (
604605 f"Encountered a level { element .level } heading ({ text_of (element )} ) at element { i } following a level { heading_level } heading ({ prev_heading } ); expected heading levels to increase by 1 level at a time. Trace: { heading_trace } "
605606 )
@@ -612,4 +613,4 @@ def _add_section_numbers(elements: Sequence[marko.element.Element]) -> None:
612613 else :
613614 element .children = [
614615 marko .block .inline .RawText (section_number )
615- ] + element .children
616+ ] + element .children # pyright: ignore[reportOperatorIssue]
0 commit comments