Skip to content

Commit 2cd1b13

Browse files
Updating string constants
1 parent b9b2fe7 commit 2cd1b13

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

classes/date/date_description_utils.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class DateDescriptionUtils:
1212
DATE_FORMAT_YYYY_MM_DD = "%Y-%m-%d"
1313
DATE_FORMAT_DD_MM_YYYY = "%d/%m/%Y"
1414

15-
# Enum name constants
16-
ENUM_VAL_NULL = "NULL"
17-
ENUM_VAL_NOT_NULL = "NOT_NULL"
15+
# string constants
16+
NULL_STRING = "NULL"
17+
NOT_NULL_STRING_UNDERSCORE = "NOT_NULL"
18+
NOT_NULL_STRING = "NOT NULL"
1819

1920
@staticmethod
2021
def interpret_date(date_field_name: str, date_value: str) -> str:
@@ -74,10 +75,10 @@ def convert_description_to_sql_date(
7475
# If the date description is in the enum, use the suggested suitable date, plus allow for NULL and NOT NULL
7576
enum_val = DateDescription.by_description_case_insensitive(date_description)
7677
if enum_val is not None:
77-
if enum_val.name == DateDescriptionUtils.ENUM_VAL_NULL:
78-
return_date_string = DateDescriptionUtils.ENUM_VAL_NULL
79-
elif enum_val.name == DateDescriptionUtils.ENUM_VAL_NOT_NULL:
80-
return_date_string = DateDescriptionUtils.ENUM_VAL_NOT_NULL
78+
if enum_val.name == DateDescriptionUtils.NULL_STRING:
79+
return_date_string = DateDescriptionUtils.NULL_STRING
80+
elif enum_val.name == DateDescriptionUtils.NOT_NULL_STRING_UNDERSCORE:
81+
return_date_string = DateDescriptionUtils.NOT_NULL_STRING
8182
else:
8283
return_date = enum_val.suitable_date
8384

@@ -137,8 +138,8 @@ def convert_description_to_local_date(
137138
enum_val = DateDescription.by_description_case_insensitive(date_description)
138139
if enum_val is not None:
139140
if enum_val.name in [
140-
DateDescriptionUtils.ENUM_VAL_NULL,
141-
DateDescriptionUtils.ENUM_VAL_NOT_NULL,
141+
DateDescriptionUtils.NULL_STRING,
142+
DateDescriptionUtils.NOT_NULL_STRING_UNDERSCORE,
142143
]:
143144
raise ValueError(f"Cannot convert '{date_description}' to a date.")
144145
if enum_val.suitable_date is not None:

0 commit comments

Comments
 (0)