Skip to content

Commit

Permalink
chore(python): Update type hinting on VerifyWebhook's signature (#1032)
Browse files Browse the repository at this point in the history
The function checks if it's None, so the type hinting should accept None

| 🚥 Resolves ISSUE_ID |
| :------------------- |

I didn't create an issue for this, but I can if that helps.

## 🧰 Changes

Update the type hinting on VerifyWebhook to accurately reflect what the
function can accept. In my application code, I call `signature` with a
variable that can be a `str` or `None`, and mypy is flagging that as a
problem because the function says it only accepts `str`.

## 🧬 QA & Testing

No testing required, since it's just a type hinting change.

I chose to use `typing.Optional[str]` instead of `str | None` because
that works on more versions of python.
  • Loading branch information
Hwesta authored Sep 3, 2024
1 parent 642c293 commit bb21b5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/python/readme_metrics/VerifyWebhook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import hmac
import json
import typing as t
from datetime import datetime, timedelta


Expand All @@ -8,7 +9,7 @@ class VerificationError(Exception):


class VerifyWebhook:
def __init__(self, body: dict, signature: str, secret: str):
def __init__(self, body: dict, signature: t.Optional[str], secret: str):
if signature is None:
raise VerificationError("Missing Signature")

Expand Down

0 comments on commit bb21b5a

Please sign in to comment.