Skip to main content

wallet

Version: 1.1.0

Building a wallet

from wexample_wallet import CredentialType, Wallet

postgres = CredentialType.from_file("credential_types/postgres.yml")

wallet = Wallet.from_dict(
    {
        "open_ai": {"type": "open_ai", "api_key": "sk-..."},
        "prod-db": {"type": "postgres", "host": "db.local", "database": "app", "user": "app"},
    },
    credential_types=[postgres],
)

Wallet.from_file() reads the same mapping from a JSON or YAML file. A credential type file lists its parameters, each required unless it says required: false:

name: postgres
label: PostgreSQL
parameters:
  - name: host
  - name: database
  - name: password
    required: false

Reading credentials

wallet.get("prod-db").get("host")                 # by credential name
wallet.get_by_type("open_ai").get("api_key")      # the first of a type
wallet.find_by_type("postgres")                   # all of a type
wallet.get("prod-db").get("port", default=5432)
wallet.has("staging")

A missing credential raises CredentialNotFoundException, naming what the wallet holds and suggesting what to add; a missing parameter raises MissingCredentialParameterException. A credential's representation never shows its parameters, so a secret cannot reach a log through it.

Table of Contents

Installation

pip install wexample-wallet

Requires Python >=3.10.

Tests

This project uses pytest for testing and pytest-cov for code coverage analysis.

Installation

First, install the required testing dependencies:

.venv/bin/python -m pip install pytest pytest-cov

Basic Usage

Run all tests with coverage:

.venv/bin/python -m pytest --cov --cov-report=html

Common Commands

# Run tests with coverage for a specific module
.venv/bin/python -m pytest --cov=your_module

# Show which lines are not covered
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing

# Generate an HTML coverage report
.venv/bin/python -m pytest --cov=your_module --cov-report=html

# Combine terminal and HTML reports
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html

# Run specific test file with coverage
.venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing

Viewing HTML Reports

After generating an HTML report, open htmlcov/index.html in your browser to view detailed line-by-line coverage information.

Coverage Threshold

To enforce a minimum coverage percentage:

.venv/bin/python -m pytest --cov=your_module --cov-fail-under=80

This will cause the test suite to fail if coverage drops below 80%.

Architecture

Three values under wexample_wallet/common/, built on wexample-helpers' BaseClass.

src/wexample_wallet/common/credential.py is a name, a type and a parameters dict. get() raises for a missing parameter unless given a default, and __repr__ leaves the parameters out.

src/wexample_wallet/common/credential_type.py describes a type: its parameters and whether each is required. from_file() reads the YAML the Syrtis registry keeps its credential types in; validate() raises for a credential lacking required parameters.

src/wexample_wallet/common/wallet.py holds the credentials by name. When built with credential types, it validates every credential of a known type; a credential of an unknown type is kept as is.

The exceptions, under exception/, follow wexample-helpers' UndefinedException: their context is in fields, the message is derived from them, and the not-found one carries a suggestion.

Integration in the Suite

This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.

The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.

Visit the Wexample Suite documentation for the complete package ecosystem.

Dependencies

  • wexample-helpers-yaml:
  • wexample-helpers: >=20.1.0

Versioning & Compatibility Policy

Wexample packages follow Semantic Versioning (SemVer):

  • MAJOR: Breaking changes
  • MINOR: New features, backward compatible
  • PATCH: Bug fixes, backward compatible

We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.

License

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

Free to use in both personal and commercial projects.

About us

Wexample stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.

This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.

Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.

Known Limitations & Roadmap

Current limitations and planned features are tracked in the GitHub issues.

See the project roadmap for upcoming features and improvements.

Status & Compatibility

Maturity: Production-ready

Python Support: >=3.10

OS Support: Linux, macOS, Windows

Status: Actively maintained

Migration Notes

When upgrading between major versions, refer to the migration guides in the documentation.

Breaking changes are clearly documented with upgrade paths and examples.

Metadata

Release files for wexample-wallet 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wexample-wallet 1.1.0
File Size Uploaded
wexample_wallet-1.1.0.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wexample-wallet 1.1.0
File Interpreter ABI Platform
wexample_wallet-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.6 kB

Release files / wexample_wallet-1.1.0.tar.gz

Download URL wexample_wallet-1.1.0.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
89566dada09a1aaffd7c84758dfaaa37b2bd1564e842eb000371091c160600bd
BLAKE2b-256 checksum
How to use checksums
71217fbff99e0bc7cee6f61675af1942105b6ea2dc3095709c477ca351a825a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.25.9 CPython/3.12.3 Linux/6.8.0-139-generic

Release files / wexample_wallet-1.1.0-py3-none-any.whl

Download URL wexample_wallet-1.1.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13da49ee7eb70ee8941cca355481f97fc79f63c61b2bde61c0bbe992931cbc4c
BLAKE2b-256 checksum
How to use checksums
5e98dde87637a4fe6fe4ff20853d64b0f0230a9b6a741a1bff3b4617d4a2fec7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.25.9 CPython/3.12.3 Linux/6.8.0-139-generic

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

This release

1.1.0 This release

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page