You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could be missing something, but why are there so many lines that try to deal with None for package_ymls and script_jsons? Why not just set the package_ymls and scipt_jsons in the init_ declaration to [] as default values?
def init(self, package_ymls=[], script_jsons=[]):
"""
package_ymls is list of filenames; script_jsons
is list of (library_name, filename) pairs.
"""
if package_ymls is None: # remove
package_ymls = [] # remove
if script_jsons is None: # remove
scripts_json = [] #remove
It's very dangerous (from a programming practice and hair-pulling perspective) to use mutable objects as defaults in python. Those get evaluated once, when python runs through that function the first time. So, if you do something like package_ymls.append() in your method, it will apply to every future invocation of the function. I've been bitten by this enough times that even if I know I'm not modifying the argument, I never use mutable default arguments in python.
I could be missing something, but why are there so many lines that try to deal with None for package_ymls and script_jsons? Why not just set the package_ymls and scipt_jsons in the init_ declaration to [] as default values?
def init(self, package_ymls=[], script_jsons=[]):
"""
package_ymls is list of filenames; script_jsons
is list of (library_name, filename) pairs.
"""
if package_ymls is None: # remove
package_ymls = [] # remove
if script_jsons is None: # remove
scripts_json = [] #remove
The text was updated successfully, but these errors were encountered: