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.1a2.tar.gz (52.1 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.1a2-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: github_webhook_types-0.0.1a2.tar.gz
  • Upload date:
  • Size: 52.1 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.1a2.tar.gz
Algorithm Hash digest
SHA256 2a6ef48841d5e814632dba18361337a3449baf052412043fb889529a6c0e0a13
MD5 f041e2a2186e570060a3abdf1a3fad83
BLAKE2b-256 3377f522c79682b29c414a47252cb39d25fbed3bf37f68a609e1e252acb23120

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for github_webhook_types-0.0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a212db02565005b9eb6170d8e6c07bf1dd95e64ab63effb7b67eebc2a99d8f5
MD5 8ab5b9af11501d0aab03d9f918374fcf
BLAKE2b-256 891f5a004504b6d6c558546186ebd677aabf2ab84154670a63bd1c2e799cf5c0

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