Skip to content

PierreLapolla/pedros

Repository files navigation

Pedros

PyPI Ruff License

A small package of reusable Python utilities for Python projects.

Features

  • Dependency Management: Smart detection of optional dependencies (rich, tqdm)
  • Logging: Simplified logging setup with optional Rich support
  • Progress Bars: Unified progress bar API with multiple backends
  • Decorators: Robust decorators for timing (@timed) and error handling (@safe)
  • Type Safe: Comprehensive type hints and PEP 561 compliance

Installation

pip install pedros

OR

uv add pedros

Optional features:

pip install "pedros[rich]"   # Rich logging/progress backend
pip install "pedros[all]"    # all optional backends

Quickstart

from pedros import setup_logging, get_logger, progbar, timed, safe

# Configure logging for pedros
setup_logging()
logger = get_logger()

# Or configure another package logger without touching root logging
setup_logging(logger_name="my_package")
logger = get_logger("my_package")

# Use progress bar (auto-selects backend: rich > tqdm > basic)
for item in progbar(range(10), desc="Processing"):
    pass

# Time function execution
@timed(logger="my_package")
def process_data():
    return "result"


process_data()  # Logs: "process_data took 1.23 ms to execute."


# Safely handle errors
@safe(re_raise=False, logger="my_package")
def risky_operation():
    raise ValueError("Something went wrong")


risky_operation()  # Logs the error but doesn't crash

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open issues or pull requests on GitHub. Before submitting contributions via pull requests, make sure the pre-commit hooks are installed. Run them manually with:

uv run pre-commit run --all-files

Support

For questions or support, please open a GitHub issue.

About

Small utility package for my projects.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages