Skip to content

Commit d790d8d

Browse files
adjusting lint issue to get passed for download_script
1 parent 4df79ea commit d790d8d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

statvar_imports/us_bea/annual_gdp/download_script.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import sys
3131
import zipfile
3232
import pandas as pd
33-
from typing import NoReturn
3433
from absl import app
3534
from absl import logging
3635

@@ -48,7 +47,7 @@
4847
os.path.dirname(os.path.abspath(__file__)), "input_files")
4948

5049

51-
def clean_up_files(directory: str) -> NoReturn:
50+
def clean_up_files(directory: str) -> None:
5251
"""
5352
Removes files from a specified directory that do not contain 'ALL_AREAS' in their filenames.
5453
@@ -67,7 +66,7 @@ def clean_up_files(directory: str) -> NoReturn:
6766
logging.error(f"Error removing file {file_path}: {e}")
6867

6968

70-
def _process_csv_data(directory: str) -> NoReturn:
69+
def _process_csv_data(directory: str) -> None:
7170
"""
7271
Processes all CSV files in the specified directory to remove spaces from specific columns.
7372
"""
@@ -88,10 +87,16 @@ def _process_csv_data(directory: str) -> NoReturn:
8887
df.to_csv(file_path, index=False)
8988
logging.info(f"Successfully processed {filename}")
9089

91-
except Exception as e:
90+
except FileNotFoundError:
91+
logging.error(f"Error: File not found at {file_path}")
92+
except pd.errors.EmptyDataError:
93+
logging.warning(f"Warning: {filename} is empty and was skipped.")
94+
except (pd.errors.ParserError, KeyError) as e:
9295
logging.error(f"Error processing {filename}: {e}")
96+
except OSError as e:
97+
logging.error(f"An OS error occurred while processing {filename}: {e}")
9398

94-
def download_and_extract_data() -> NoReturn:
99+
def download_and_extract_data() -> None:
95100
"""
96101
Downloads and extracts the BEA annual GDP data.
97102
@@ -147,7 +152,7 @@ def download_and_extract_data() -> NoReturn:
147152
else:
148153
logging.error("Failed to download the file.")
149154

150-
def main() -> NoReturn:
155+
def main() -> None:
151156
"""
152157
Main function to orchestrate the download and extraction process.
153158
"""

0 commit comments

Comments
 (0)