added typing.Union

This commit is contained in:
ayxan 2022-11-23 00:39:06 +04:00
parent 749c8c7bad
commit cd19c54876

View File

@ -2,21 +2,22 @@ import pandas as pd
from datetime import (datetime, from datetime import (datetime,
timedelta) timedelta)
from typing import (List, from typing import (List,
Tuple) Tuple,
Union)
class DataOperations: class DataOperations:
heart_rate = None heart_rate = None
def is_data_none_wrapper(func): def is_data_none_wrapper(func):
def __is_data_none(self, *args, **kwargs) -> None | NameError: def __is_data_none(self, *args, **kwargs) -> Union[None, NameError]:
if self.data is None: if self.data is None:
raise NameError(f'data not found. You must call the get_data function before calling the {func.__name__} function') raise NameError(f'data not found. You must call the get_data function before calling the {func.__name__} function')
return func(self, *args, **kwargs) return func(self, *args, **kwargs)
return __is_data_none return __is_data_none
def is_heart_rate_none_wrapper(func): def is_heart_rate_none_wrapper(func):
def __is_heart_rate_none(self, *args, **kwargs) -> None | NameError: def __is_heart_rate_none(self, *args, **kwargs) -> Union[None, NameError]:
if self.heart_rate is None: if self.heart_rate is None:
raise NameError(f'heart_rate data not found. You must call the get_heart_rate function before calling the {func.__name__} function') raise NameError(f'heart_rate data not found. You must call the get_heart_rate function before calling the {func.__name__} function')
return func(self, *args, **kwargs) return func(self, *args, **kwargs)