Created
June 20, 2020 01:05
-
-
Save metaperl/5b30e2487d32350691a30360a0076b89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Re - https://pypi.org/project/sphinx-autodoc-typehints/ | |
# Re - https://www.reddit.com/r/Python/comments/hcc7d9/any_emerging_peps_on_unifying_type_hints_with_doc/ | |
from typing import Union | |
def format_unit( | |
value: Union[float, int] # a numeric value, | |
unit: str # the unit for the value (kg, m, etc.) | |
) -> str: | |
""" | |
Formats the given value as a human readable string using the given units. | |
""" | |
return '{} {}'.format(value, unit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment