Skip to content

Commit bb21b5a

Browse files
authored
chore(python): Update type hinting on VerifyWebhook's signature (#1032)
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.
1 parent 642c293 commit bb21b5a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/python/readme_metrics/VerifyWebhook.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import json
21
import hmac
2+
import json
3+
import typing as t
34
from datetime import datetime, timedelta
45

56

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

910

1011
class VerifyWebhook:
11-
def __init__(self, body: dict, signature: str, secret: str):
12+
def __init__(self, body: dict, signature: t.Optional[str], secret: str):
1213
if signature is None:
1314
raise VerificationError("Missing Signature")
1415

0 commit comments

Comments
 (0)