Skip to main content

pure-protobuf

GitHub Workflow Status Code coverage PyPI - Downloads PyPI – Version PyPI – Python License

Wow! Such annotated! Very buffers!

Documentation

Documentation

Quick examples

.proto definition

It's not needed for pure-protobuf, but for the sake of an example, let's consider the following definition:

syntax = "proto3";

message SearchRequest {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
}

And here's the same via pure-protobuf:

With dataclasses

from dataclasses import dataclass
from io import BytesIO

from pure_protobuf.annotations import Field
from pure_protobuf.message import BaseMessage
from typing_extensions import Annotated


@dataclass
class SearchRequest(BaseMessage):
    query: Annotated[str, Field(1)] = ""
    page_number: Annotated[int, Field(2)] = 0
    result_per_page: Annotated[int, Field(3)] = 0


request = SearchRequest(query="hello", page_number=1, result_per_page=10)
buffer = bytes(request)
assert buffer == b"\x0A\x05hello\x10\x01\x18\x0A"
assert SearchRequest.read_from(BytesIO(buffer)) == request

With pydantic

from io import BytesIO

from pure_protobuf.annotations import Field
from pure_protobuf.message import BaseMessage
from pydantic import BaseModel
from typing_extensions import Annotated


class SearchRequest(BaseMessage, BaseModel):
    query: Annotated[str, Field(1)] = ""
    page_number: Annotated[int, Field(2)] = 0
    result_per_page: Annotated[int, Field(3)] = 0


request = SearchRequest(query="hello", page_number=1, result_per_page=10)
buffer = bytes(request)
assert buffer == b"\x0A\x05hello\x10\x01\x18\x0A"
assert SearchRequest.read_from(BytesIO(buffer)) == request

Metadata

Release files for pure-protobuf 3.1.5

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

Source distribution (sdist)

Source distribution for pure-protobuf 3.1.5
File Size Uploaded Provenance Actions
pure_protobuf-3.1.5.tar.gz 17.4 kB Without provenance Details for pure_protobuf-3.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pure-protobuf 3.1.5
File Interpreter ABI Platform Actions
pure_protobuf-3.1.5-py3-none-any.whl Python 3 none any Details for pure_protobuf-3.1.5-py3-none-any.whl

Total release size: 45.5 kB

Release files / pure_protobuf-3.1.5.tar.gz

Download URL pure_protobuf-3.1.5.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2e33554cbe2e664a099546f6fd1d6130e409df2d7a8c68b6ee9ce56f4c5d6dfc
BLAKE2b-256 checksum
How to use checksums
11492bbc64c052c63a63ba5c9af561734e8e5c6e440b1ce325617fca4b5ecea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.12.3 Linux/6.11.0-1018-azure

Release files / pure_protobuf-3.1.5-py3-none-any.whl

Download URL pure_protobuf-3.1.5-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7e9f57522d6e6f04f683cb4cded4eecfb18a1912b5a4aaed1745c1265f5620a
BLAKE2b-256 checksum
How to use checksums
f4efcad3d78e86f75a56e64d238d73393d37cf5c874d31819735ae2dba35e4b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.12.3 Linux/6.11.0-1018-azure

Security for pure-protobuf 3.1.5

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

3.1.5 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