German-Immersive-Railroading-Community / BackupSystem

Consider iterating dictionary PYL-C0201
Anti-pattern
Major
2 years ago2 years old
Consider iterating the dictionary directly instead of calling .keys()
 66    lg.warning('There was something wrong with the data.json; fixing...')
 67if not 'sha' in data.keys():
 68    data['sha'] = {}
 69if not 'last' in data.keys(): 70    lg.warning('No last update date found; setting standard')
 71    data['last'] = '1999-12-01'
 72
Consider iterating the dictionary directly instead of calling .keys()
 64    lg.warning('data.json not found; creating...')
 65except json.JSONDecodeError:
 66    lg.warning('There was something wrong with the data.json; fixing...')
 67if not 'sha' in data.keys(): 68    data['sha'] = {}
 69if not 'last' in data.keys():
 70    lg.warning('No last update date found; setting standard')