Typing Stubs for humanfriendly
This is a PEP 561 type stub package providing static type annotations for the `humanfriendly` library. It enables type-checking tools like MyPy, Pyright, and PyCharm to analyze code that uses `humanfriendly`. While available on PyPI, this package is part of the Typeshed project, and direct maintenance for it has ceased; fixes should be contributed upstream to Typeshed. This version aims to provide accurate annotations for `humanfriendly==10.0.*`.
Warnings
- deprecated The `types-humanfriendly` package is officially unmaintained on PyPI, and the `humanfriendly` stubs were removed from the upstream Typeshed project in March 2025. This means no further updates or fixes will be provided.
- gotcha Stub versions can introduce breaking changes for type checkers even if the runtime library does not. Due to the unmaintained status, future `humanfriendly` versions may not be accurately stubbed, leading to type-checking errors.
- gotcha The underlying `humanfriendly` library itself has not been updated since September 2021 (version 10.0) and was noted as not working with Python 3.13 during the Typeshed removal discussion, which implies potential runtime issues with newer Python versions, separate from the stubs.
Install
-
pip install types-humanfriendly -
pip install humanfriendly
Imports
- format_size
from humanfriendly import format_size
- parse_size
from humanfriendly import parse_size
- prompt_for_input
from humanfriendly.prompts import prompt_for_input
Quickstart
import os
from humanfriendly import format_size, parse_size
def process_size(size_str: str) -> str:
try:
num_bytes = parse_size(size_str)
return f"You entered: {format_size(num_bytes)}"
except Exception as e:
return f"Error parsing size: {e}"
# Example usage (usually from user input or a configuration)
user_input = os.environ.get('EXAMPLE_FILE_SIZE', '10GB') # Simulate input
print(process_size(user_input))