PythonistaGuild/TwitchIO

PartialUser.id is a string but documented as int

Gouvernathor opened this issue · 5 comments

A User or PartialUser's id is supposed to be an int, according to the docs, but in practice the property returns a string, which gives gorgeous equality failures at runtime.
That is, in the 2.6.0 version that came out of pip at least.

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.

Hi, all PartialUser and User ids are ints.

Are you sure you are not confusing these with Chatters? Which are not Users / PartialUsers.

Yes, that's probably that. I was using ctx.author, and it turns out it was a Chatter. The author field would gain from being documented though.

Author is documented here:
https://twitchio.dev/en/latest/reference.html#twitchio.Message.author

Context
self.author: Union[Chatter, PartialChatter] = message.author

Does your linter not provide you with this information?
I'll look to add extra documentation for Context to assist those who are struggling, as demonstrated here.

The linter does hint it's a Chatter though I hadn't paid attention to it (and if I had I'm not sure I would have trusted it), and it hinted me the id in the first place. I'm not sure if there could be a way to tell the linter it it's a private field in the case of Chatters.

It's a documented field for Message but not for Context as you saw, and it's not clear to me how to get a Message from a Context, either. It only seems it takes one Message as parameter ? but it's not clear what it does with it.