jensengroup / propka

PROPKA predicts the pKa values of ionizable groups in proteins and protein-ligand complexes based in the 3D structure.
http://propka.org
GNU Lesser General Public License v2.1
263 stars 58 forks source link

Remove array-valued default arguments from methods #56

Closed sobolevnrm closed 8 months ago

sobolevnrm commented 4 years ago

Example in:

https://github.com/jensengroup/propka-3.1/blob/dde0d67ea5d7b0e8b24a3050ae4d6cbc4ca07972/propka/molecular_container.py#L198

Pylint finds several other examples

sobolevnrm commented 4 years ago

In general, I need to better understand the general problems behind mutable default values. https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html

orbeckst commented 4 years ago

My understanding is that unless one really wants to keep track of multiple function invocations in a global variable that is effectively hidden from global view, one should just follow the advice in the quantifiedcode link and use def(value=None) and value = value if value is not None else [] (or similar).