@@ -46,7 +46,8 @@ def _infer(a, b):
4646 if b and b .tzinfo :
4747 if not (tslib .get_timezone (tz ) == tslib .get_timezone (b .tzinfo )):
4848 raise AssertionError ('Inputs must both have the same timezone,'
49- ' {0} != {1}' .format (tz , b .tzinfo ))
49+ ' {timezone1} != {timezone2}'
50+ .format (timezone1 = tz , timezone2 = b .tzinfo ))
5051 return tz
5152
5253 tz = None
@@ -491,10 +492,10 @@ def _convert_listlike(arg, box, format, name=None, tz=tz):
491492 offset = tslib .Timestamp (origin ) - tslib .Timestamp (0 )
492493 except tslib .OutOfBoundsDatetime :
493494 raise tslib .OutOfBoundsDatetime (
494- "origin {} is Out of Bounds" .format (origin ))
495+ "origin {origin } is Out of Bounds" .format (origin = origin ))
495496 except ValueError :
496- raise ValueError ("origin {} cannot be converted "
497- "to a Timestamp" .format (origin ))
497+ raise ValueError ("origin {origin } cannot be converted "
498+ "to a Timestamp" .format (origin = origin ))
498499
499500 # convert the offset to the unit of the arg
500501 # this should be lossless in terms of precision
@@ -590,16 +591,16 @@ def f(value):
590591 required = ['year' , 'month' , 'day' ]
591592 req = sorted (list (set (required ) - set (unit_rev .keys ())))
592593 if len (req ):
593- raise ValueError ("to assemble mappings requires at "
594- "least that [year, month, day] be specified: "
595- "[{0}] is missing" .format (',' .join (req )))
594+ raise ValueError ("to assemble mappings requires at least that "
595+ "[year, month, day] be specified: [{required}] "
596+ "is missing" .format (required = ',' .join (req )))
596597
597598 # keys we don't recognize
598599 excess = sorted (list (set (unit_rev .keys ()) - set (_unit_map .values ())))
599600 if len (excess ):
600601 raise ValueError ("extra keys have been passed "
601602 "to the datetime assemblage: "
602- "[{0 }]" .format (',' .join (excess )))
603+ "[{excess }]" .format (',' .join (excess = excess )))
603604
604605 def coerce (values ):
605606 # we allow coercion to if errors allows
@@ -617,7 +618,7 @@ def coerce(values):
617618 values = to_datetime (values , format = '%Y%m%d' , errors = errors )
618619 except (TypeError , ValueError ) as e :
619620 raise ValueError ("cannot assemble the "
620- "datetimes: {0 }" .format (e ))
621+ "datetimes: {error }" .format (error = e ))
621622
622623 for u in ['h' , 'm' , 's' , 'ms' , 'us' , 'ns' ]:
623624 value = unit_rev .get (u )
@@ -627,8 +628,8 @@ def coerce(values):
627628 unit = u ,
628629 errors = errors )
629630 except (TypeError , ValueError ) as e :
630- raise ValueError ("cannot assemble the datetimes "
631- "[{0}]: {1} " .format (value , e ))
631+ raise ValueError ("cannot assemble the datetimes [{value}]: "
632+ "{error} " .format (value = value , error = e ))
632633
633634 return values
634635
@@ -810,8 +811,10 @@ def _convert_listlike(arg, format):
810811 times .append (datetime .strptime (element , format ).time ())
811812 except (ValueError , TypeError ):
812813 if errors == 'raise' :
813- raise ValueError ("Cannot convert %s to a time with "
814- "given format %s" % (element , format ))
814+ msg = ("Cannot convert {element} to a time with given "
815+ "format {format}" ).format (element = element ,
816+ format = format )
817+ raise ValueError (msg )
815818 elif errors == 'ignore' :
816819 return arg
817820 else :
@@ -876,6 +879,7 @@ def ole2datetime(oledt):
876879 # Excel has a bug where it thinks the date 2/29/1900 exists
877880 # we just reject any date before 3/1/1900.
878881 if val < 61 :
879- raise ValueError ("Value is outside of acceptable range: %s " % val )
882+ msg = "Value is outside of acceptable range: {value}" .format (value = val )
883+ raise ValueError (msg )
880884
881885 return OLE_TIME_ZERO + timedelta (days = val )
0 commit comments