Skip to content

Commit

Permalink
Added docs for bit conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-matei committed Jan 8, 2024
1 parent 3feb7c5 commit 23fd3f3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pydantic/types.py
Expand Up @@ -1834,11 +1834,13 @@ def human_readable(self, decimal: bool = False) -> str:
return f'{num:0.1f}{final_unit}'

def to(self, unit: str) -> float:
"""Converts a byte size to another unit.
"""Converts a byte size to another unit, including both byte and bit units.
Args:
unit: The unit to convert to. Must be one of the following: B, KB, MB, GB, TB, PB, EiB,
KiB, MiB, GiB, TiB, PiB, EiB.
unit: The unit to convert to. Must be one of the following: B, KB, MB, GB, TB, PB, EB,
KiB, MiB, GiB, TiB, PiB, EiB (byte units) and
bit, kbit, mbit, gbit, tbit, pbit, ebit,
kibit, mibit, gibit, tibit, pibit, eibit (bit units).
Returns:
The byte size in the new unit.
Expand Down

0 comments on commit 23fd3f3

Please sign in to comment.