@@ -408,7 +408,7 @@ class FormattedTime(dt.time):
408408 ("" , ".%f" ),
409409 ("%p" , "%P" , "" ),
410410 ("%z" , "" ),
411- )
411+ ),
412412 )
413413 ) + list (
414414 # 12 hour time pattern combinations
@@ -419,7 +419,7 @@ class FormattedTime(dt.time):
419419 ("" , ".%f" ),
420420 ("%z" , "" ),
421421 (" %p" , "%p" , "%P" , " %P" , "" ),
422- )
422+ ),
423423 )
424424 )
425425 """A sequence of time format patterns to try if `TIME_FORMAT` is unset."""
@@ -454,9 +454,9 @@ def parse_time(cls, string: str) -> dt.time:
454454 raise ValueError ("Unable to parse provided time" )
455455
456456 @classmethod
457- def validate (cls , value : Optional [ Union [dt .time , dt .datetime , str ] ]) -> dt .time | None :
457+ def validate (cls , value : Union [dt .time , dt .datetime , str ]) -> dt .time | None :
458458 """Validate a passed time, datetime or string."""
459- if not value :
459+ if value is None :
460460 return value
461461
462462 if isinstance (value , dt .time ):
@@ -466,8 +466,8 @@ def validate(cls, value: Optional[Union[dt.time, dt.datetime, str]]) -> dt.time
466466 else :
467467 if cls .TIME_FORMAT is not None :
468468 try :
469- new_time = dt .datetime .strptime (value , cls .TIME_FORMAT )
470- new_time = cls .convert_to_time (new_time )
469+ new_time = dt .datetime .strptime (value , cls .TIME_FORMAT ) # type: ignore
470+ new_time = cls .convert_to_time (new_time ) # type: ignore
471471 except ValueError as err :
472472 raise ValueError (
473473 f"Unable to parse provided time in format { cls .TIME_FORMAT } "
@@ -478,9 +478,7 @@ def validate(cls, value: Optional[Union[dt.time, dt.datetime, str]]) -> dt.time
478478 if cls .TIMEZONE_TREATMENT == "forbid" and new_time .tzinfo :
479479 raise ValueError ("Provided time has timezone, but this is forbidden for this field" )
480480 if cls .TIMEZONE_TREATMENT == "require" and not new_time .tzinfo :
481- raise ValueError (
482- "Provided time missing timezone, but this is required for this field"
483- )
481+ raise ValueError ("Provided time missing timezone, but this is required for this field" )
484482
485483 return new_time
486484
0 commit comments