if details['box'] == {} or details['box'][last_box_key].get('timeout', datetime.min) < datetime.now():
I tried putting brackets around the dict but I cant seem to break this really long line.
if details['box'] == {} or details['box'][last_box_key].get('timeout', datetime.min) < datetime.now():
I tried putting brackets around the dict but I cant seem to break this really long line.
You can break the line up using backslashes.
if details['box'] == {} or \
details['box'][last_box_key].get('timeout', datetime.min) \
< datetime.now():
Use black Python code formatter (note: by default, it formats in-place, i.e. mutates the file, use --diff
flag to make it just output the changes).
Running black test.py
formats your code to:
if (
details["box"] == {}
or details["box"][last_box_key].get("timeout", datetime.min) < datetime.now()
):
By adding more keys, you may find out how black will split even longer line:
if (
details["box"] == {}
or details["box"][last_box_key][another_very_long_key][
even_more_looooooong_key
].get("timeout", datetime.min)
< datetime.now()
):