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.1.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.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: core_extensions-2.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 aca67d15df6d91210c13e60a806bae3374a5b8a1937421a7a0a8bbae3850119d
MD5 d871f0e5d4c3d95b15cfe289c0cf4071
BLAKE2b-256 8fd9c9cd7ead77dc545e113cc36ccf6847bbf41fe7e14039f2bfe89849d00a06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for core_extensions-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c41766dc3a7bc761c39569f4fb395d53cd49a2ec20c54abbfd0a1a16d99bf7f
MD5 a44bb354756e6e8b6a6f8fa3288393b0
BLAKE2b-256 06b90809b01a73acc1d837315b8749fb960d2ad5b047b95c5dd92dd8af62cea5

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