PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
798 stars 162 forks source link

models.py Stream :: game_id, game_name attribute could be empty string #328

Closed ccppoo closed 2 years ago

ccppoo commented 2 years ago

image

There are cases where streamer didn't set their game_name while streaming.

Unlike Twitch System automatically generates Tags after few seconds like I mentioned at https://github.com/TwitchIO/TwitchIO/issues/324 ,

game_id, game_name weren't generated until the streamer changes it.

There was no explanations in case of game_id and game_name sent as empty string in Twitch API Doc.

and couldn't find other cases like this in blogs, stackoverflow questions.

github-actions[bot] commented 2 years ago

Hello! Thanks for the issue. If this is a general help question, for a faster response consider joining the official Discord Server

Else if you have an issue with the library please wait for someone to help you here.

chillymosh commented 2 years ago

Twitch does indeed send these as empty strings rather than None or null type and the models reflect this, as per their documentation.

'game_id': '', 'game_name': '', 'type': 'live',

Whether we change the model to make these Optional or not and return None by simply adding or None, or a property, to the model will need to be discussed, or left as a change for 3.0

ccppoo commented 2 years ago

@chillymosh yes, it will be better using @property decorators saving origin values(str) and then handling,

such as type casting string to int or empty string to None could be more useful for future maintenance

so does issue https://github.com/TwitchIO/TwitchIO/issues/325 and https://github.com/TwitchIO/TwitchIO/issues/324

IAmTomahawkx commented 2 years ago

We will not be changing this, as it is true to the API, and changes made to turn this to None or whatever constitute a breaking change.

ccppoo commented 2 years ago

Not in the docs, nor TwitchIO Doc somebody just getting a exception not knowing what just happend in runtime and you are saying API is working fine all time