13
13
from datetime import datetime
14
14
from pathlib import Path
15
15
from types import SimpleNamespace
16
- from typing import Iterator , List , TextIO , Tuple , Union
16
+ from typing import Iterator , TextIO , Union
17
17
18
18
19
19
def nested_simplenamespace_to_dict (
@@ -157,7 +157,7 @@ def flatten(element: Union[str, bytes, Iterable]) -> Iterator[str]:
157
157
158
158
159
159
def parent_logger_card_html (
160
- name : str , * args : List [Iterator [str ]]
160
+ name : str , * args : list [Iterator [str ]]
161
161
) -> Iterator [str ]:
162
162
"""
163
163
Generate the HTML for a parent logger card.
@@ -212,7 +212,7 @@ def child_logger_card(log) -> Iterator[str]:
212
212
213
213
214
214
def child_logger_card_html (
215
- name : str , duration : str , * args : Union [Iterator [str ], List [Iterator [str ]]]
215
+ name : str , duration : str , * args : Union [Iterator [str ], list [Iterator [str ]]]
216
216
) -> Iterator [str ]:
217
217
"""
218
218
Generate the HTML for a child logger card.
@@ -480,7 +480,7 @@ def command_card(log: dict, stream_dir: Path) -> Iterator[str]:
480
480
481
481
482
482
def time_series_plot (
483
- cmd_id : str , data_tuples : List [ Tuple [float , float ]], series_title : str
483
+ cmd_id : str , data_tuples : list [ tuple [float , float ]], series_title : str
484
484
) -> Iterator [str ]:
485
485
"""
486
486
Create the HTML for a plot of time series data.
@@ -501,7 +501,7 @@ def time_series_plot(
501
501
502
502
503
503
def disk_time_series_plot (
504
- cmd_id : str , data_tuples : Tuple [ float , float ], volume_name : str
504
+ cmd_id : str , data_tuples : list [ tuple [ float , float ] ], volume_name : str
505
505
) -> Iterator [str ]:
506
506
"""
507
507
Generate a time series plot of disk usage.
@@ -530,7 +530,7 @@ def disk_time_series_plot(
530
530
531
531
532
532
def stat_chart_card (
533
- labels : List [str ], data : List [float ], title : str , identifier : str
533
+ labels : list [str ], data : list [float ], title : str , identifier : str
534
534
) -> Iterator [str ]:
535
535
"""
536
536
Create the HTML for a two-dimensional plot.
@@ -676,7 +676,7 @@ def output_block_html(
676
676
677
677
def split_template (
678
678
template : str , split_at : str , ** kwargs
679
- ) -> Tuple [str , str , str ]:
679
+ ) -> tuple [str , str , str ]:
680
680
"""
681
681
Subdivide a HTML template.
682
682
@@ -854,7 +854,7 @@ def sgr_4bit_color_and_style_to_html(sgr: str) -> str:
854
854
return f'<span style="{ sgr_to_css .get (sgr ) or str ()} ">'
855
855
856
856
857
- def sgr_8bit_color_to_html (sgr_params : List [str ]) -> str : # noqa: PLR0911
857
+ def sgr_8bit_color_to_html (sgr_params : list [str ]) -> str : # noqa: PLR0911
858
858
"""
859
859
Convert 8-bit SGR colors to HTML.
860
860
@@ -866,6 +866,10 @@ def sgr_8bit_color_to_html(sgr_params: List[str]) -> str: # noqa: PLR0911
866
866
867
867
Returns:
868
868
A HTML ``span`` with the appropriate CSS style.
869
+
870
+ Raises:
871
+ RuntimeError: If the code somehow falls through all the `if`
872
+ blocks without returning. This should never happen.
869
873
"""
870
874
sgr_256 = int (sgr_params [2 ]) if len (sgr_params ) > 2 else 0
871
875
if sgr_256 < 0 or sgr_256 > 255 or not sgr_params :
@@ -891,10 +895,11 @@ def sgr_8bit_color_to_html(sgr_params: List[str]) -> str: # noqa: PLR0911
891
895
return sgr_4bit_color_and_style_to_html (str (40 + sgr_256 ))
892
896
if sgr_256 < 16 :
893
897
return sgr_4bit_color_and_style_to_html (str (92 + sgr_256 ))
894
- return "THIS SHOULD NEVER HAPPEN"
898
+ message = "THIS SHOULD NEVER HAPPEN"
899
+ raise RuntimeError (message )
895
900
896
901
897
- def sgr_24bit_color_to_html (sgr_params : List [str ]) -> str :
902
+ def sgr_24bit_color_to_html (sgr_params : list [str ]) -> str :
898
903
"""
899
904
Convert 24-bit SGR colors to HTML.
900
905
0 commit comments