Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: allow parsing webhook with event name of type str #123

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions codegen/templates/webhooks/_namespace.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ class WebhookNamespace:
def parse(name: EventNameType, payload: Union[str, bytes]) -> "WebhookEvent":
...

@overload
@staticmethod
def parse(name: EventNameType, payload: Union[str, bytes]) -> "WebhookEvent":
def parse(name: str, payload: Union[str, bytes]) -> "WebhookEvent":
...

@staticmethod
def parse(name: Union[EventNameType, str], payload: Union[str, bytes]) -> "WebhookEvent":
"""Parse the webhook payload with event name.

Args:
Expand Down Expand Up @@ -105,8 +110,13 @@ class WebhookNamespace:
def parse_obj(name: EventNameType, payload: Dict[str, Any]) -> "WebhookEvent":
...

@overload
@staticmethod
def parse_obj(name: EventNameType, payload: Dict[str, Any]) -> "WebhookEvent":
def parse_obj(name: str, payload: Dict[str, Any]) -> "WebhookEvent":
...

@staticmethod
def parse_obj(name: Union[EventNameType, str], payload: Dict[str, Any]) -> "WebhookEvent":
"""Parse the webhook payload dict with event name.

Args:
Expand Down
16 changes: 14 additions & 2 deletions githubkit/versions/ghec_v2022_11_28/webhooks/_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,14 @@
@staticmethod
def parse(name: EventNameType, payload: Union[str, bytes]) -> "WebhookEvent": ...

@overload
@staticmethod
def parse(name: str, payload: Union[str, bytes]) -> "WebhookEvent": ...

@staticmethod
def parse(name: EventNameType, payload: Union[str, bytes]) -> "WebhookEvent":
def parse(

Check warning on line 624 in githubkit/versions/ghec_v2022_11_28/webhooks/_namespace.py

View check run for this annotation

Codecov / codecov/patch

githubkit/versions/ghec_v2022_11_28/webhooks/_namespace.py#L624

Added line #L624 was not covered by tests
name: Union[EventNameType, str], payload: Union[str, bytes]
) -> "WebhookEvent":
"""Parse the webhook payload with event name.

Args:
Expand Down Expand Up @@ -1007,8 +1013,14 @@
@staticmethod
def parse_obj(name: EventNameType, payload: Dict[str, Any]) -> "WebhookEvent": ...

@overload
@staticmethod
def parse_obj(name: str, payload: Dict[str, Any]) -> "WebhookEvent": ...

@staticmethod
def parse_obj(name: EventNameType, payload: Dict[str, Any]) -> "WebhookEvent":
def parse_obj(

Check warning on line 1021 in githubkit/versions/ghec_v2022_11_28/webhooks/_namespace.py

View check run for this annotation

Codecov / codecov/patch

githubkit/versions/ghec_v2022_11_28/webhooks/_namespace.py#L1021

Added line #L1021 was not covered by tests
name: Union[EventNameType, str], payload: Dict[str, Any]
) -> "WebhookEvent":
"""Parse the webhook payload dict with event name.

Args:
Expand Down
16 changes: 14 additions & 2 deletions githubkit/versions/v2022_11_28/webhooks/_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,14 @@ def parse(
@staticmethod
def parse(name: EventNameType, payload: Union[str, bytes]) -> "WebhookEvent": ...

@overload
@staticmethod
def parse(name: str, payload: Union[str, bytes]) -> "WebhookEvent": ...

@staticmethod
def parse(name: EventNameType, payload: Union[str, bytes]) -> "WebhookEvent":
def parse(
name: Union[EventNameType, str], payload: Union[str, bytes]
) -> "WebhookEvent":
"""Parse the webhook payload with event name.

Args:
Expand Down Expand Up @@ -981,8 +987,14 @@ def parse_obj(
@staticmethod
def parse_obj(name: EventNameType, payload: Dict[str, Any]) -> "WebhookEvent": ...

@overload
@staticmethod
def parse_obj(name: str, payload: Dict[str, Any]) -> "WebhookEvent": ...

@staticmethod
def parse_obj(name: EventNameType, payload: Dict[str, Any]) -> "WebhookEvent":
def parse_obj(
name: Union[EventNameType, str], payload: Dict[str, Any]
) -> "WebhookEvent":
"""Parse the webhook payload dict with event name.

Args:
Expand Down
Loading