PythonistaGuild / TwitchIO

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

PartialUser.id is a string but documented as int #399

Closed Gouvernathor closed 1 year ago

Gouvernathor commented 1 year ago

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.

github-actions[bot] commented 1 year 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 1 year ago

Hi, all PartialUser and User ids are ints.

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

Gouvernathor commented 1 year ago

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.

chillymosh commented 1 year ago

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.

Gouvernathor commented 1 year ago

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.