Skip to content

Commit 7759f86

Browse files
author
Eviee Py
committed
Merge branch 'dev/3.0' of https://github.com/PythonistaGuild/Twitchio into dev/3.0
2 parents fec3b5c + 37ba7ca commit 7759f86

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

twitchio/http.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from .models.subscriptions import BroadcasterSubscription, BroadcasterSubscriptions
5858
from .models.videos import Video
5959
from .user import ActiveExtensions, PartialUser
60-
from .utils import Colour, _from_json, handle_user_ids, url_encode_datetime # type: ignore
60+
from .utils import Colour, _from_json, date_to_datetime_with_z, handle_user_ids, url_encode_datetime # type: ignore
6161

6262

6363
if TYPE_CHECKING:
@@ -538,9 +538,6 @@ def get_extension_analytics(
538538
if extension_id:
539539
params["extension_id"] = extension_id
540540

541-
def date_to_datetime_with_z(date: datetime.date) -> str:
542-
return datetime.datetime.combine(date, datetime.time(0, 0)).isoformat() + "Z"
543-
544541
if started_at and ended_at:
545542
params["started_at"] = date_to_datetime_with_z(started_at)
546543
params["ended_at"] = date_to_datetime_with_z(ended_at)
@@ -570,9 +567,6 @@ def get_game_analytics(
570567
if game_id:
571568
params["game_id"] = game_id
572569

573-
def date_to_datetime_with_z(date: datetime.date) -> str:
574-
return datetime.datetime.combine(date, datetime.time(0, 0)).isoformat() + "Z"
575-
576570
if started_at and ended_at:
577571
params["started_at"] = date_to_datetime_with_z(started_at)
578572
params["ended_at"] = date_to_datetime_with_z(ended_at)
@@ -1161,7 +1155,7 @@ async def post_chat_shoutout(
11611155
token_for: str | PartialUser,
11621156
) -> None:
11631157
params = {
1164-
"broadcaster_id": broadcaster_id,
1158+
"from_broadcaster_id": broadcaster_id,
11651159
"moderator_id": moderator_id,
11661160
"to_broadcaster_id": to_broadcaster_id,
11671161
}

twitchio/models/eventsub_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ class ChannelRaid(BaseEvent):
19441944

19451945
subscription_type = "channel.raid"
19461946

1947-
__slots__ = ("from_broadcaster", "to_boradcaster", "viewer_count")
1947+
__slots__ = ("from_broadcaster", "to_broadcaster", "viewer_count")
19481948

19491949
def __init__(self, payload: ChannelRaidEvent, *, http: HTTPClient) -> None:
19501950
self.from_broadcaster: PartialUser = PartialUser(

twitchio/utils.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import asyncio
44
import colorsys
5+
import datetime
56
import json
67
import logging
78
import os
89
import pathlib
910
import struct
1011
import sys
1112
from collections.abc import Callable
12-
from datetime import UTC, datetime
1313
from functools import wraps
1414
from typing import TYPE_CHECKING, Any, Generic, Self, TypeVar, cast
1515
from urllib.parse import quote
@@ -40,6 +40,7 @@
4040
"MISSING",
4141
"handle_user_ids",
4242
"_is_submodule",
43+
"date_to_datetime_with_z",
4344
)
4445

4546
T_co = TypeVar("T_co", covariant=True)
@@ -90,7 +91,7 @@ def stream_supports_rgb(stream: Any) -> bool:
9091
return False
9192

9293

93-
def parse_timestamp(timestamp: str) -> datetime:
94+
def parse_timestamp(timestamp: str) -> datetime.datetime:
9495
"""
9596
Parses a timestamp in ISO8601 format to a datetime object.
9697
@@ -104,7 +105,7 @@ def parse_timestamp(timestamp: str) -> datetime:
104105
datetime.datetime
105106
The parsed datetime object.
106107
"""
107-
return datetime.fromisoformat(timestamp)
108+
return datetime.datetime.fromisoformat(timestamp)
108109

109110

110111
class ColourFormatter(logging.Formatter):
@@ -733,7 +734,7 @@ def chunk_list(sequence: list[Any], n: int) -> Generator[Any, Any, Any]:
733734
yield sequence[i : i + n]
734735

735736

736-
def url_encode_datetime(dt: datetime) -> str:
737+
def url_encode_datetime(dt: datetime.datetime) -> str:
737738
"""
738739
Formats a datetime object to an RFC 3339 compliant string and URL-encodes it.
739740
If the datetime object does not have a timezone, it is converted to UTC first.
@@ -748,7 +749,7 @@ def url_encode_datetime(dt: datetime) -> str:
748749
str
749750
The URL encoded parsed datetime object.
750751
"""
751-
formatted_dt = dt.replace(tzinfo=UTC).isoformat() if dt.tzinfo is None else dt.isoformat()
752+
formatted_dt = dt.replace(tzinfo=datetime.UTC).isoformat() if dt.tzinfo is None else dt.isoformat()
752753

753754
return quote(formatted_dt)
754755

@@ -841,4 +842,8 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
841842

842843

843844
def _is_submodule(parent: str, child: str) -> bool:
844-
return parent == child or child.startswith(parent + ".")
845+
return parent == child or child.startswith(f"{parent}.")
846+
847+
848+
def date_to_datetime_with_z(date: datetime.date) -> str:
849+
return f"{datetime.datetime.combine(date, datetime.time(0, 0)).isoformat()}Z"

0 commit comments

Comments
 (0)