Skip to content

Commit

Permalink
✨ Feature: allow parsing webhook with event name of type str (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
fau-st authored Aug 8, 2024
1 parent 4f2e025 commit 7083819
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
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 @@ 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 @@ -1007,8 +1013,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
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

0 comments on commit 7083819

Please sign in to comment.