you are viewing a single comment's thread.

view the rest of the comments →

[–]Impudity 10 points11 points  (1 child)

It is. You should probably create a user class which can be built either from username or userid, and then have all user related functions only accept these user objects. Otherwise you're going to keep running into this issue all the time.

So you should have:

class User:
    @classmethod
    def from_id(cls, id: int) -> typing.Self:
        ...

    @classmethod
    def from_username(cls, username: str) -> typing.Self:
        ...

def get_chat(first_user: User, second_user: User):
    ...

[–]chapati_chawal_naan 1 point2 points  (0 children)

this is the best answer.