mirror of
https://github.com/Textualize/rich.git
synced 2025-08-19 09:50:42 +00:00
Added optional type hinting
This commit is contained in:
parent
9564ac5462
commit
74ae964858
1 changed files with 4 additions and 4 deletions
|
@ -13,15 +13,15 @@ See Also:
|
||||||
|
|
||||||
__all__ = ["decimal"]
|
__all__ = ["decimal"]
|
||||||
|
|
||||||
from typing import Iterable, List, Tuple
|
from typing import Iterable, List, Tuple, Optional
|
||||||
|
|
||||||
|
|
||||||
def _to_str(
|
def _to_str(
|
||||||
size: int,
|
size: int,
|
||||||
suffixes: Iterable[str],
|
suffixes: Iterable[str],
|
||||||
base: int,
|
base: int,
|
||||||
precision: int = 1,
|
precision: Optional[int] = 1,
|
||||||
separator: str = " ",
|
separator: Optional[str] = " ",
|
||||||
) -> str:
|
) -> str:
|
||||||
if size == 1:
|
if size == 1:
|
||||||
return "1 byte"
|
return "1 byte"
|
||||||
|
@ -49,7 +49,7 @@ def pick_unit_and_suffix(size: int, suffixes: List[str], base: int) -> Tuple[int
|
||||||
return unit, suffix
|
return unit, suffix
|
||||||
|
|
||||||
|
|
||||||
def decimal(size: int, precision: int = 1, separator: str = " ") -> str:
|
def decimal(size: int, precision: Optional[int] = 1, separator: Optional[str] = " ") -> str:
|
||||||
"""Convert a filesize in to a string (powers of 1000, SI prefixes).
|
"""Convert a filesize in to a string (powers of 1000, SI prefixes).
|
||||||
|
|
||||||
In this convention, ``1000 B = 1 kB``.
|
In this convention, ``1000 B = 1 kB``.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue