Skip to main content

Combadge

Combadge generates a service client implementation from a user service interface declared by a protocol class or an abstract base class.

Checks Coverage Code style Python Version License

Documentation

Documentation

Sneak peek

from httpx import Client
from pydantic import BaseModel, Field
from typing_extensions import Annotated, Protocol

from combadge.support.http.markers import QueryParam, http_method, path
from combadge.support.httpx.backends.sync import HttpxBackend


# 1️⃣ Declare the response models:
class CurrentCondition(BaseModel):
    humidity: int
    temperature: Annotated[float, Field(alias="temp_C")]


class Weather(BaseModel):
    current: Annotated[list[CurrentCondition], Field(alias="current_condition")]


# 2️⃣ Declare the protocol:
class SupportsWttrIn(Protocol):
    @http_method("GET")
    @path("/{in_}")
    def get_weather(
        self,
        *,
        in_: str,
        format_: Annotated[str, QueryParam("format")] = "j1",
    ) -> Weather:
        raise NotImplementedError


# 3️⃣ Bind the service:
with HttpxBackend(Client(base_url="https://wttr.in"))[SupportsWttrIn] as service:
    # 🚀 Call the service:
    response = service.get_weather(in_="amsterdam")

assert response.current[0].humidity == 71
assert response.current[0].temperature == 8.0

Metadata

Release files for combadge 6.0.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 combadge 6.0.0
File Size Uploaded Provenance Actions
combadge-6.0.0.tar.gz 23.4 kB Without provenance Details for combadge-6.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for combadge 6.0.0
File Interpreter ABI Platform Actions
combadge-6.0.0-py3-none-any.whl Python 3 none any Details for combadge-6.0.0-py3-none-any.whl

Total release size: 62.0 kB

Release files / combadge-6.0.0.tar.gz

Download URL combadge-6.0.0.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a58f452d696e4142eb6ae40cb598f2b5bec23b08c3667f9f90e03bbb03792b4e
BLAKE2b-256 checksum
How to use checksums
4139d3aeb9763f0cce12d1541fe9db1d91be3220520b1949e3b0c26245ef589d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.14.4 Linux/7.0.0-1020-azure

Release files / combadge-6.0.0-py3-none-any.whl

Download URL combadge-6.0.0-py3-none-any.whl
Size 38.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c952361935e7d8ff212544dbaf76136c4392bfb28c2fcfb2a480986a6837c89f
BLAKE2b-256 checksum
How to use checksums
927541d66ec586f2561ac8e8f48c82b1adf46ab3ed423ba63d22bc64ea098604
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.1 CPython/3.14.4 Linux/7.0.0-1020-azure

Security for combadge 6.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.0.0 This release

2 release files No provenance

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