chore: Improve typing

This commit is contained in:
Matthias 2024-07-07 08:36:51 +02:00
parent 9f628309e9
commit ffb0cf1a2c
2 changed files with 11 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import csv
import logging
import sys
from typing import Any, Dict, List
from typing import Any, Dict, List, Union
import rapidjson
from rich.console import Console
@ -80,10 +80,10 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
def _print_objs_tabular(objs: List, print_colorized: bool) -> None:
names = [s["name"] for s in objs]
objs_to_print = [
objs_to_print: List[Dict[str, Union[Text, str]]] = [
{
"name": Text(s["name"] if s["name"] else "--"),
"location": Text(s["location_rel"]),
"location": s["location_rel"],
"status": (
Text("LOAD FAILED", style="bold red")
if s["class"] is None
@ -103,7 +103,7 @@ def _print_objs_tabular(objs: List, print_colorized: bool) -> None:
"sell-Params": str(len(s["hyperoptable"].get("sell", []))),
}
)
table = Table(title="Available:")
table = Table()
for header in objs_to_print[0].keys():
table.add_column(header.capitalize(), justify="right")

View File

@ -1,13 +1,17 @@
import sys
from typing import Any, Dict, List, Optional
from typing import Any, Dict, Optional, Sequence, Union
from rich.console import Console
from rich.table import Table
from rich.text import Text
TextOrString = Union[str, Text]
def print_rich_table(
tabular_data: List[Dict[str, Any]],
headers: List[str],
tabular_data: Sequence[Union[Dict[str, Any], Sequence[TextOrString]]],
headers: Sequence[str],
summary: Optional[str] = None,
*,
table_kwargs: Optional[Dict[str, Any]] = None,