Skip to main content

TypedDict and Pydantic models for GitHub webhook payloads.

Project description

github-webhook-types

TypedDict definitions and Pydantic models for GitHub webhook payloads.

The package generates its public payload types from Octokit's machine-readable webhook schema. The schema JSON is not vendored in this repository; generated metadata records the upstream package versions and SHA256 hashes used to create the committed Python modules.

Install

pip install github-webhook-types

Usage

from github_webhook_types import GitHubEventName, parse_delivery
from github_webhook_types.generated.models import IssuesOpenedPayload
from github_webhook_types.generated.typed_dicts import IssuesOpenedPayloadDict

event: GitHubEventName = "issues"
payload = parse_delivery(event, b'{"action": "opened", "repository": {}, "sender": {}, "issue": {}}')

typed_payload: IssuesOpenedPayloadDict = {
    "action": "opened",
    "repository": {},
    "sender": {},
    "issue": {},
}
model = IssuesOpenedPayload.model_validate(typed_payload)

parse_delivery() dispatches by X-GitHub-Event and, when present, the payload action. Unknown GitHub fields are accepted by the generated Pydantic models so new fields do not immediately break consumers.

Type Source

Generated payload types come from:

  • https://unpkg.com/@octokit/webhooks-schemas/schema.json
  • https://unpkg.com/@octokit/webhooks-examples/api.github.com/index.json

The current source metadata is exported from github_webhook_types.generated._schema_meta.

Development

pdm install
pdm run generate
pdm run quality
pdm run docs:build
pdm run docs:preview
pdm run docs:dev

Use pdm run generate:check to verify that the committed generated files still match the current Octokit schema metadata. Use pdm run docs:preview to serve the built site/ directory, and pdm run docs:dev for Zensical's live docs server.

License

ISC.

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

github_webhook_types-0.0.1a3.tar.gz (149.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github_webhook_types-0.0.1a3-py3-none-any.whl (112.1 kB view details)

Uploaded Python 3

File details

Details for the file github_webhook_types-0.0.1a3.tar.gz.

File metadata

  • Download URL: github_webhook_types-0.0.1a3.tar.gz
  • Upload date:
  • Size: 149.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.9 CPython/3.14.5 Linux/6.17.0-1013-azure

File hashes

Hashes for github_webhook_types-0.0.1a3.tar.gz
Algorithm Hash digest
SHA256 f60399a4e2f75cbabb2c48e6edf6c87c4b2cb8d34a3e2e7bf9a648612a897034
MD5 d4cd118c547c0274bfef62aa3df94c3b
BLAKE2b-256 7118c7dcbff6acf9378af5f99460161300029e20a5bb719ebd09a81c368edf86

See more details on using hashes here.

File details

Details for the file github_webhook_types-0.0.1a3-py3-none-any.whl.

File metadata

File hashes

Hashes for github_webhook_types-0.0.1a3-py3-none-any.whl
Algorithm Hash digest
SHA256 06b4721aba1ea57547629f22c01bc90dc9b3bddedf6a601201215477a37b821a
MD5 db3afcdd00f4563454ba72442f16d91c
BLAKE2b-256 884d1e0f12d998728b3e12aba80b7550a20b6f7483ea12877e8519f1b9336574

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