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.0.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.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: core_extensions-2.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 ec8f9f28b7314e7c400009c9ca4acbfef03b46089d7d310fb57c1d5472adc0fc
MD5 a2a67e4fc5ea4219533ecd133dbe664d
BLAKE2b-256 e1b0f5268850a41becdbb0e62e3d18c58d08aefa57266085fd42357f7a4babd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for core_extensions-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5946bd13d5bb0cd05a824ef19644fb3aa67b4c9a8b07e4f3c9a2633e6dd9550e
MD5 d93dd0ed86b73f6b5e2cf5cba5d4c6cb
BLAKE2b-256 83ec3aa286f2073aef0e577dd97dce6f3c49d2486e3d732930a84f5146e8e8bc

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