Skip to main content

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

Project description

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

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:

Commands:
  deploy  Deploy the application  (aliases: release, publish)
  infra   Infrastructure commands  (aliases: i, infrastructure)

Registering the same alias on two different commands raises ValueError immediately at decoration time, preventing silent routing bugs.

By default a subgroup is a plain click.Group, so its commands do not support aliases. Pass cls=AliasedGroup to enable full alias support at every level:

@cli.group("db", aliases=["database"], cls=AliasedGroup)
def db_group():
    """Database commands"""

@db_group.command("migrate", aliases=["m"])
def db_migrate():
    """Run pending migrations"""

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]"

Testing

The project ships two complementary test suites:

  • Unit tests — isolated, mocked, deterministic; one file per module.

  • Integration tests — end-to-end scenarios using Click’s CliRunner and live tenacity retry machinery; no mocking of internal collaborators.

tests/
├── unit/
│   ├── cli/tests_aliased_group.py
│   └── decorators/tests_retry.py
└── integration/
    ├── test_cli_integration.py
    └── test_retry_integration.py

Run unit tests only:

pytest tests/unit/

Run integration tests only:

pytest tests/integration/

Run both suites with branch coverage:

pytest tests/ --cov=core_extensions --cov-branch --cov-report=term-missing

Or use the helper script:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

core_extensions-2.0.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

core_extensions-2.0.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file core_extensions-2.0.1.tar.gz.

File metadata

  • Download URL: core_extensions-2.0.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for core_extensions-2.0.1.tar.gz
Algorithm Hash digest
SHA256 bb1093069064179a860a1a687cc1c9944ae2ec1d4e743660e98ad4634e2a18fa
MD5 864732f4b1d8e7f32b9652330cbc45c6
BLAKE2b-256 f82241e8300621a18c40f63bd0558119387e91e0611d870784a4dbba973fa3e2

See more details on using hashes here.

File details

Details for the file core_extensions-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for core_extensions-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f27d1ffc002c8ed11f5b08ce2cfa5ff04246b66ddf08b997b96faf72f899f98
MD5 27e6f4a9afb5a2c4fe705f36e7880f2c
BLAKE2b-256 108f9de2defcf795dc38184383b1237e40bda1b8df350854a8c20f4e2a2174ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page