From 60f25de710fbaed222873ad076c88fdf44456831 Mon Sep 17 00:00:00 2001 From: gouravkr Date: Tue, 1 Mar 2022 15:34:16 +0530 Subject: [PATCH] changed pos = [] to *pos in date_parser decorator --- fincal/core.py | 4 ++-- fincal/fincal.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fincal/core.py b/fincal/core.py index 3f3ab7c..79f053a 100644 --- a/fincal/core.py +++ b/fincal/core.py @@ -17,14 +17,14 @@ class Frequency: symbol: str -def date_parser(pos): +def date_parser(*pos): def parse_dates(func): def wrapper_func(*args, **kwargs): date_format = kwargs.get("date_format", None) args = list(args) sig = inspect.signature(func) params = [i[0] for i in sig.parameters.items()] - # print(params) + for j in pos: kwarg = params[j] date = kwargs.get(kwarg, None) diff --git a/fincal/fincal.py b/fincal/fincal.py index aa703cd..4d1bd2e 100644 --- a/fincal/fincal.py +++ b/fincal/fincal.py @@ -184,7 +184,7 @@ class TimeSeries(TimeSeriesCore): return self.__class__(new_ts, frequency=self.frequency.symbol) - @date_parser(pos=[1]) + @date_parser(1) def calculate_returns( self, as_on: Union[str, datetime.datetime], @@ -277,7 +277,7 @@ class TimeSeries(TimeSeriesCore): returns = returns ** (1 / years) return (current[0] if return_actual_date else as_on), returns - 1 - @date_parser(pos=[1, 2]) + @date_parser(1, 2) def calculate_rolling_returns( self, from_date: Union[datetime.date, str],