core-extensions#
This project contains common elements for different projects. Unlike core-mixins,
this project requires external dependencies…
Documentation Contents#
Index:
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#
Install required libraries:
pip install --upgrade pip
pip install virtualenv
Create Python virtual environment:
virtualenv --python=python3.12 .venv
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:
Fork the repository
Create a feature branch
Write tests for new functionality
Ensure all tests pass:
pytest -n autoRun linting:
pylint core_extensionsRun security checks:
bandit -r core_extensionsSubmit a pull request
License#
This project is licensed under the MIT License. See the LICENSE file for details.
Links#
Support#
For questions or support, please open an issue on GitLab or contact the maintainers.