mayukh18 / BlindChat

a facebook messenger bot that allows users to chat with other people on facebook anonymously
https://m.me/blindchat.go/
MIT License
111 stars 127 forks source link

Bug: Usage of mutable default arguments #72

Open adityamahapatra opened 3 years ago

adityamahapatra commented 3 years ago

Description

I was skimming through the code and came across a bug. In the generic template module, there's a GenericTemplate class that contains the add_template function. The function contains a kwarg, buttons, which defaults to an empty list. Using a mutable object as a default argument has unintended consequences and should be avoided.

Recommendation

This is from the official Python docs: Function definitions. Refer to the definition of the whats_on_the_telly function under this section.

Context

The issue is described in further detail here: Avoid mutable default arguments.

I haven't gone through the entire code base so can't say if this is the only instance or not.

Cheers, Aditya

okayjones commented 3 years ago

Opened up a small PR for this issue!