Typing Stubs for humanfriendly

10.0.1.20250319 · deprecated · verified Mon Apr 13

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

Install

Imports

Quickstart

Install `humanfriendly` and `types-humanfriendly`. Then, import and use functions from `humanfriendly` with type annotations. Your type checker will leverage the stubs provided by `types-humanfriendly`.

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))

view raw JSON →