inflate() year_or_month type error not catching years as string format
nhstaple opened this issue · 1 comments
nhstaple commented
I'm using a dataset that stores dates as strings "YYYY-MM-DD". I sliced the first four characters, then inflate complained without providing useful error information.
Converting the year_or_month parameter to an integer and performing the check would solve this issue. Also, one could check if the type is a string and provide a more useful TypeError() msg.
if type(year_or_month) != type(to):
raise TypeError("Years can only be converted to other years. Months only to other months.")
https://github.com/datadesk/cpi/blob/36d049b45a3f318df97dbced56fbc12dd55415e2/cpi/__init__.py#L138
palewire commented
I'd welcome a pull request on this. Will close pending that.