From 345c5feebce58d7df8ad666ba6764c6e038e3341 Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Wed, 3 Jul 2024 11:47:31 +0200 Subject: [PATCH] Add None check for fieldnames to avoid warnings --- main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.py b/main.py index 0d5eaa8..9510a2f 100644 --- a/main.py +++ b/main.py @@ -100,6 +100,10 @@ def create_box(row, fieldnames: list[str], reviewer_ids: set) -> str: with open(args.comment_file, 'r', encoding='utf8') as csv_file: reader = csv.DictReader(csv_file) + if reader.fieldnames is None: + print("Unable to detect columns in CSV file") + sys.exit() + if len(reader.fieldnames) < MIN_FIELDS: print( f'CSV file must have at least {MIN_FIELDS} columns but has {len(reader.fieldnames)}'