python-wechaty icon indicating copy to clipboard operation
python-wechaty copied to clipboard

difference signature with `Contact.say` and `Room.say`

Open alingse opened this issue 4 years ago • 2 comments

Room

async def say(self,
                  some_thing: Union[str, Contact, FileBox, MiniProgram, UrlLink],
                  mention_ids: Optional[List[str]] = None
                  ) -> Union[None, Message]:
    async def say(self, message: Union[str, Message, FileBox, Contact, UrlLink]
                  ) -> Optional[Message]:
        """
        say something
        :param message: message content
        """

and my error case

        conversation: Union[Room, Contact] = self.get_conversation()
        await conversation.ready()
        await conversation.say(some_thing=some_thing, mention_ids=mention_ids)  # error here.
  1. can we use same signature def say(some_thing, mention_ids=None) and ignore mention_ids in Contact

or only use same first param name some_thing ?

所以我想要不要统一下 say 的签名? 或者能不能把 Contact 的 say 第一个签名改成一样的 some_thing

如果 ok 我可以提一个 MR, 是稍微有点 break

alingse avatar Sep 12 '21 16:09 alingse

Thanks for your issue to describe the details between Contact.say and Room.say. I think this is the design of wechaty pacakge.

There are some friendly designs in different packages and modules, we should keep every pacakge and module as simple & isolated as possible. So, in contact module, Contact.say method should only say something not with mention_ids which is not the parameter of it. I understand that if we support it in package, so that you will not occur the lingting issue in your local development. But I this is the bad design for python-wechaty. And what's more, this linting issue can be fixied with your self design in your bot code, and I think this is the simple design. Do you think so ? @alingse

But anyway, you have a deep understanding about python-wechaty details. We'd love to have you onboard the development of python-wechaty.

wj-Mcat avatar Sep 28 '21 05:09 wj-Mcat

I known Contact.say is different with Room.say, may the first arg name some_thing, message can be unified ?

alingse avatar Oct 05 '21 12:10 alingse