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 5.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 5.0.0
File Size Uploaded Provenance
combadge-5.0.0.tar.gz 25.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 64.0 kB

Release files / combadge-5.0.0.tar.gz

Download URL combadge-5.0.0.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c6548f35d8100ea3f125678fc73d76d48025f393e21533f79685f9741bf5d597
BLAKE2b-256 checksum
How to use checksums
6fd39f1a7a7ca7e37e2fe1154c1a9830428d4ec34e941a7c99e11f9c4074b2da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.3 Linux/6.11.0-1018-azure

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

Download URL combadge-5.0.0-py3-none-any.whl
Size 38.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
957435e5e9879fbc428afa7071a5211ec0a89deeafca1eeff099930f8cda15d6
BLAKE2b-256 checksum
How to use checksums
92ba0f70577472a590774436f746062a310dfb7799dfd711cd7bee3740f24e8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.3 Linux/6.11.0-1018-azure

Security for combadge 5.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

5.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