Skip to content

Commit

Permalink
better create_error in csv_upload
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourpeas committed Jun 11, 2024
1 parent ab44a13 commit c6b363d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions project/npda/general_functions/csv_upload.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# python imports
from datetime import date
import time
import logging
import os
from typing import Literal
Expand Down Expand Up @@ -222,10 +223,10 @@ def create_error(
"""
Creates error object from item, list and string text
"""
item_match = False
for choice in allowed_list:
if choice[0] == list_item:
item_match = True
# Convert allowed_list to a dictionary if it's not already one
allowed_dict = {choice[0]: choice[1] for choice in allowed_list}
# Check if list_item is in the dictionary
item_match = list_item in allowed_dict

if item_match:
# all items are valid, no errors
Expand Down

0 comments on commit c6b363d

Please sign in to comment.