Skip to content

Commit e612234

Browse files
committed
updates to simplify code
1 parent 6a7431d commit e612234

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

labelbox/schema/project.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import logging
44
import time
5+
from tkinter import E
56
import warnings
67
from collections import namedtuple
78
from datetime import datetime, timezone
@@ -278,13 +279,11 @@ def _string_from_dict(dictionary: dict, value_with_quotes=False) -> str:
278279
279280
The string will be formatted as {key}: 'value' for each key. Value will be inclusive of
280281
quotations while key will not. This can be toggled with `value_with_quotes`"""
281-
if value_with_quotes:
282-
return ",".join([
283-
f"""{c}: "{dictionary.get(c)}\"""" for c in dictionary
284-
if dictionary.get(c)
285-
])
282+
283+
quote = "\"" if value_with_quotes else ""
286284
return ",".join([
287-
f"""{c}: {dictionary.get(c)}""" for c in dictionary
285+
f"""{c}: {quote}{dictionary.get(c)}{quote}"""
286+
for c in dictionary
288287
if dictionary.get(c)
289288
])
290289

@@ -293,7 +292,7 @@ def _validate_datetime(string_date: str) -> bool:
293292
if string_date:
294293
try:
295294
datetime.strptime(string_date, "%Y-%m-%d")
296-
except:
295+
except ValueError:
297296
raise ValueError(f"""Incorrect format for: {string_date}.
298297
Format must be \"YYYY-MM-DD\"""")
299298
return True

0 commit comments

Comments
 (0)