From 3c8d3ab078af6918968dad3acaea9a37da3f187c Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 19 Apr 2021 02:12:41 -0400 Subject: [PATCH] Add a third overload to parse_time Apparently this behaviour is intended in Pyright https://github.com/microsoft/pyright/issues/1772 Despite mypy behaving as intended. --- discord/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/discord/utils.py b/discord/utils.py index 06a4dea21..7316b62ed 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -175,6 +175,11 @@ def parse_time(timestamp: str) -> datetime.datetime: ... +@overload +def parse_time(timestamp: Optional[str]) -> Optional[datetime.datetime]: + ... + + def parse_time(timestamp: Optional[str]) -> Optional[datetime.datetime]: if timestamp: return datetime.datetime.fromisoformat(timestamp) @@ -389,6 +394,7 @@ def get(iterable: Iterable[T], **attrs: Any) -> Optional[T]: def _unique(iterable: Iterable[T]) -> List[T]: return [x for x in dict.fromkeys(iterable)] + def _get_as_snowflake(data: Any, key: str) -> Optional[int]: try: value = data[key]