core-extensions#

This project contains common elements for different projects. Unlike core-mixins, this project requires external dependencies…


Python Versions License Pipeline Status Docs Status Security

Documentation Contents#

Installation#

Install from PyPI using pip:

pip install core-extensions
uv pip install core-extensions  # Or using UV...

Features#

This library provides a collection of utilities and extensions for projects:

Retry Decorator Advanced retry mechanism based on the tenacity library with exponential backoff, custom exception handling, and detailed logging.

from core_extensions.decorators.retry import SimpleRetry

retry_handler = SimpleRetry(max_attempts=3, base_delay=1.0)

@retry_handler.create_decorator((ConnectionError, TimeoutError))
def fetch_data():
    return api.get_data()

Aliased CLI Group Click extension that allows defining command aliases for better user experience and backward compatibility in CLI applications.

from core_extensions.cli import AliasedGroup

cli = AliasedGroup()

@cli.command("deploy", aliases=["release", "publish"])
def deploy_command():
    """Deploy the application"""
    print("Deploying...")

@cli.group("infra", aliases=["i", "infrastructure"])
def infra_group():
    """Infrastructure commands"""

Aliases are shown automatically in --help output, and registering the same alias on two commands raises ValueError at decoration time.

Quick Start#

Installation#

Install the package:

pip install core-extensions
uv pip install core-extensions  # Or using UV...
pip install -e ".[dev]"         # For development...

Setting Up Environment#

  1. Install required libraries:

pip install --upgrade pip
pip install virtualenv
  1. Create Python virtual environment:

virtualenv --python=python3.12 .venv
  1. Activate the virtual environment:

source .venv/bin/activate

Install packages#

pip install .
pip install -e ".[dev]"

Check tests and coverage#

python manager.py run-tests
python manager.py run-coverage

Contributing#

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Write tests for new functionality

  4. Ensure all tests pass: pytest -n auto

  5. Run linting: pylint core_extensions

  6. Run security checks: bandit -r core_extensions

  7. Submit a pull request

License#

This project is licensed under the MIT License. See the LICENSE file for details.

Support#

For questions or support, please open an issue on GitLab or contact the maintainers.

Authors#