Awesome. But before merging, could you change the line if time_period: to if time_period in time_mapping:?
This way we do the same as in your line, plus checking if the key is in the list, in order not to raise a KeyError if someone sets time_period='potato' or something similar.
Note: this work perfectly unless someone weirdly decides to add a False key to the time_mapping array. If you wanna be really sure, and I think this would be a nicer way, the condition should be
Awesome. But before merging, could you change the line
if time_period:
toif time_period in time_mapping:
?This way we do the same as in your line, plus checking if the key is in the list, in order not to raise a KeyError if someone sets
time_period='potato'
or something similar.Note: this work perfectly unless someone weirdly decides to add a
False
key to the time_mapping array. If you wanna be really sure, and I think this would be a nicer way, the condition should beif time_period and time_period in time_mapping:
Thanks!