chore: improve rhci_progress typing, remove mutable arguments

This commit is contained in:
Matthias 2024-09-01 08:27:53 +02:00
parent c6b46d75cb
commit b25520cf18

View File

@ -1,13 +1,20 @@
from typing import Callable, List, Union from typing import Callable, List, Optional, Union
from rich.console import ConsoleRenderable, Group, RichCast from rich.console import ConsoleRenderable, Group, RichCast
from rich.progress import Progress from rich.progress import Progress
class CustomProgress(Progress): class CustomProgress(Progress):
def __init__(self, *args, cust_objs=[], cust_callables: List[Callable] = [], **kwargs) -> None: def __init__(
self._cust_objs = cust_objs self,
self._cust_callables = cust_callables *args,
cust_objs: Optional[List[ConsoleRenderable]] = None,
cust_callables: Optional[List[Callable[[], ConsoleRenderable]]] = None,
**kwargs,
) -> None:
self._cust_objs = cust_objs or []
self._cust_callables = cust_callables or []
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def get_renderable(self) -> Union[ConsoleRenderable, RichCast, str]: def get_renderable(self) -> Union[ConsoleRenderable, RichCast, str]: