@@ -46,7 +46,8 @@ def _infer(a, b):
46
46
if b and b .tzinfo :
47
47
if not (tslib .get_timezone (tz ) == tslib .get_timezone (b .tzinfo )):
48
48
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 ))
50
51
return tz
51
52
52
53
tz = None
@@ -491,10 +492,10 @@ def _convert_listlike(arg, box, format, name=None, tz=tz):
491
492
offset = tslib .Timestamp (origin ) - tslib .Timestamp (0 )
492
493
except tslib .OutOfBoundsDatetime :
493
494
raise tslib .OutOfBoundsDatetime (
494
- "origin {} is Out of Bounds" .format (origin ))
495
+ "origin {origin } is Out of Bounds" .format (origin = origin ))
495
496
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 ))
498
499
499
500
# convert the offset to the unit of the arg
500
501
# this should be lossless in terms of precision
@@ -590,16 +591,16 @@ def f(value):
590
591
required = ['year' , 'month' , 'day' ]
591
592
req = sorted (list (set (required ) - set (unit_rev .keys ())))
592
593
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 )))
596
597
597
598
# keys we don't recognize
598
599
excess = sorted (list (set (unit_rev .keys ()) - set (_unit_map .values ())))
599
600
if len (excess ):
600
601
raise ValueError ("extra keys have been passed "
601
602
"to the datetime assemblage: "
602
- "[{0 }]" .format (',' .join (excess )))
603
+ "[{excess }]" .format (',' .join (excess = excess )))
603
604
604
605
def coerce (values ):
605
606
# we allow coercion to if errors allows
@@ -617,7 +618,7 @@ def coerce(values):
617
618
values = to_datetime (values , format = '%Y%m%d' , errors = errors )
618
619
except (TypeError , ValueError ) as e :
619
620
raise ValueError ("cannot assemble the "
620
- "datetimes: {0 }" .format (e ))
621
+ "datetimes: {error }" .format (error = e ))
621
622
622
623
for u in ['h' , 'm' , 's' , 'ms' , 'us' , 'ns' ]:
623
624
value = unit_rev .get (u )
@@ -627,8 +628,8 @@ def coerce(values):
627
628
unit = u ,
628
629
errors = errors )
629
630
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 ))
632
633
633
634
return values
634
635
@@ -810,8 +811,10 @@ def _convert_listlike(arg, format):
810
811
times .append (datetime .strptime (element , format ).time ())
811
812
except (ValueError , TypeError ):
812
813
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 )
815
818
elif errors == 'ignore' :
816
819
return arg
817
820
else :
@@ -876,6 +879,7 @@ def ole2datetime(oledt):
876
879
# Excel has a bug where it thinks the date 2/29/1900 exists
877
880
# we just reject any date before 3/1/1900.
878
881
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 )
880
884
881
885
return OLE_TIME_ZERO + timedelta (days = val )
0 commit comments