From 888cdfbce67de78221402f52969663a11fb37045 Mon Sep 17 00:00:00 2001 From: Ali Moghimi Date: Mon, 23 Oct 2023 10:44:58 +0000 Subject: [PATCH] style: add typing --- scraper/engine.py | 2 +- transformer/agent.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scraper/engine.py b/scraper/engine.py index 253203b..bcef3d0 100644 --- a/scraper/engine.py +++ b/scraper/engine.py @@ -10,7 +10,7 @@ def __init__(self, url, max_retries, backoff_factor) -> None: self.url = url self.request = Request(max_retries=max_retries, backoff_factor=backoff_factor) - def fetch(self, content=None) -> pd.DataFrame: + def fetch(self, content: str = None) -> pd.DataFrame: logger.debug(f"Attempting to fetch content from {self.url}.") if not content: content = self.get_content() diff --git a/transformer/agent.py b/transformer/agent.py index 3174558..4872722 100644 --- a/transformer/agent.py +++ b/transformer/agent.py @@ -41,7 +41,7 @@ def transform(self) -> pd.DataFrame: logger.debug(f"\n{self.dataframe}") return self.dataframe - def parse_date(self): + def parse_date(self) -> None: try: self.dataframe["Clearing Date"] = pd.to_datetime( self.dataframe["Clearing Date"], format="%Y-%m-%d" @@ -53,26 +53,26 @@ def parse_date(self): logger.error(f"Failed to parse dates. Error: {e}") raise - def add_timestamp(self): + def add_timestamp(self) -> None: try: self.dataframe["timestamp_created_utc"] = datetime.datetime.utcnow() except Exception as e: logger.error(f"Failed to add timestamps. Error: {e}") raise - def rename_columns(self): + def rename_columns(self) -> None: try: self.dataframe.rename(columns=self.COLUMNS_NAME, inplace=True) except Exception as e: logger.error(f"Failed to rename columns. Error: {e}") raise - def brakedown_instrument_name(self): + def brakedown_instrument_name(self) -> None: try: df_split = self.dataframe["Instrument Name"].str.split( ".", n=5, expand=True ) - print(df_split) + logger.debug(f"\n{df_split}") df_split.columns = [ "Ticker", "Tier",