Open wertysas opened 2 weeks ago
Thanks, that's a good observation. Unfortunately, your proposed solution would bear dangerous side effects because using a dict as the default argument makes it effectively a global variable, see for example:
>>> def routine_with_opt_arg(arg={}):
... arg['test'] = arg.get('test', 0) + 1
... print(arg)
...
>>> routine_with_opt_arg()
{'test': 1}
>>> routine_with_opt_arg()
{'test': 2}
>>> routine_with_opt_arg()
{'test': 3}
The correct pattern for this is instead to add a manual check to the constructor:
if config is None:
config = {}
The default argument for the config in the Scheduler leads to a runtime error. However, the documentation of the Scheduler class says that the config parameter is optional.
It seems to me that an easy fix could be to change the default argument from None to {}