@@ -161,8 +161,7 @@ def round_nsint64(values, mode, freq):
161
161
162
162
# if/elif above should catch all rounding modes defined in enum 'RoundTo':
163
163
# if flow of control arrives here, it is a bug
164
- raise ValueError (" round_nsint64 called with an unrecognized "
165
- " rounding mode" )
164
+ raise ValueError (" round_nsint64 called with an unrecognized rounding mode" )
166
165
167
166
168
167
# ----------------------------------------------------------------------
@@ -324,8 +323,10 @@ class Timestamp(_Timestamp):
324
323
325
324
Function is not implemented. Use pd.to_datetime().
326
325
"""
327
- raise NotImplementedError (" Timestamp.strptime() is not implemented."
328
- " Use to_datetime() to parse date strings." )
326
+ raise NotImplementedError (
327
+ " Timestamp.strptime() is not implemented. "
328
+ " Use to_datetime() to parse date strings."
329
+ )
329
330
330
331
@classmethod
331
332
def combine (cls , date , time ):
@@ -381,8 +382,9 @@ class Timestamp(_Timestamp):
381
382
if tzinfo is not None :
382
383
if not PyTZInfo_Check(tzinfo):
383
384
# tzinfo must be a datetime.tzinfo object, GH#17690
384
- raise TypeError (f' tzinfo must be a datetime.tzinfo object, '
385
- f' not {type(tzinfo)}' )
385
+ raise TypeError (
386
+ f" tzinfo must be a datetime.tzinfo object, not {type(tzinfo)}"
387
+ )
386
388
elif tz is not None :
387
389
raise ValueError (' Can provide at most one of tz, tzinfo' )
388
390
@@ -393,8 +395,10 @@ class Timestamp(_Timestamp):
393
395
# User passed a date string to parse.
394
396
# Check that the user didn't also pass a date attribute kwarg.
395
397
if any (arg is not None for arg in _date_attributes):
396
- raise ValueError (' Cannot pass a date attribute keyword '
397
- ' argument when passing a date string' )
398
+ raise ValueError (
399
+ " Cannot pass a date attribute keyword "
400
+ " argument when passing a date string"
401
+ )
398
402
399
403
elif ts_input is _no_input:
400
404
# User passed keyword arguments.
@@ -578,8 +582,10 @@ timedelta}, default 'raise'
578
582
@tz.setter
579
583
def tz (self , value ):
580
584
# GH 3746: Prevent localizing or converting the index by setting tz
581
- raise AttributeError (" Cannot directly set timezone. Use tz_localize() "
582
- " or tz_convert() as appropriate" )
585
+ raise AttributeError (
586
+ " Cannot directly set timezone. "
587
+ " Use tz_localize() or tz_convert() as appropriate"
588
+ )
583
589
584
590
def __setstate__ (self , state ):
585
591
self .value = state[0 ]
@@ -598,9 +604,10 @@ timedelta}, default 'raise'
598
604
599
605
if self .tz is not None :
600
606
# GH#21333
601
- warnings.warn(" Converting to Period representation will "
602
- " drop timezone information." ,
603
- UserWarning )
607
+ warnings.warn(
608
+ " Converting to Period representation will drop timezone information." ,
609
+ UserWarning ,
610
+ )
604
611
605
612
if freq is None :
606
613
freq = self .freq
@@ -810,13 +817,13 @@ default 'raise'
810
817
if ambiguous == ' infer' :
811
818
raise ValueError (' Cannot infer offset with only one time.' )
812
819
813
- nonexistent_options = (' raise' , ' NaT' , ' shift_forward' ,
814
- ' shift_backward' )
820
+ nonexistent_options = (' raise' , ' NaT' , ' shift_forward' , ' shift_backward' )
815
821
if nonexistent not in nonexistent_options and not isinstance (
816
822
nonexistent, timedelta):
817
- raise ValueError (" The nonexistent argument must be one of 'raise', "
818
- " 'NaT', 'shift_forward', 'shift_backward' or "
819
- " a timedelta object" )
823
+ raise ValueError (
824
+ " The nonexistent argument must be one of 'raise', "
825
+ " 'NaT', 'shift_forward', 'shift_backward' or a timedelta object"
826
+ )
820
827
821
828
if self .tzinfo is None :
822
829
# tz naive, localize
@@ -833,8 +840,9 @@ default 'raise'
833
840
value = tz_convert_single(self .value, UTC, self .tz)
834
841
return Timestamp(value, tz = tz, freq = self .freq)
835
842
else :
836
- raise TypeError (' Cannot localize tz-aware Timestamp, use '
837
- ' tz_convert for conversions' )
843
+ raise TypeError (
844
+ " Cannot localize tz-aware Timestamp, use tz_convert for conversions"
845
+ )
838
846
839
847
def tz_convert (self , tz ):
840
848
"""
@@ -857,17 +865,28 @@ default 'raise'
857
865
"""
858
866
if self .tzinfo is None :
859
867
# tz naive, use tz_localize
860
- raise TypeError (' Cannot convert tz-naive Timestamp, use '
861
- ' tz_localize to localize' )
868
+ raise TypeError (
869
+ " Cannot convert tz-naive Timestamp, use tz_localize to localize"
870
+ )
862
871
else :
863
872
# Same UTC timestamp, different time zone
864
873
return Timestamp(self .value, tz = tz, freq = self .freq)
865
874
866
875
astimezone = tz_convert
867
876
868
- def replace (self , year = None , month = None , day = None ,
869
- hour = None , minute = None , second = None , microsecond = None ,
870
- nanosecond = None , tzinfo = object , fold = 0 ):
877
+ def replace (
878
+ self ,
879
+ year = None ,
880
+ month = None ,
881
+ day = None ,
882
+ hour = None ,
883
+ minute = None ,
884
+ second = None ,
885
+ microsecond = None ,
886
+ nanosecond = None ,
887
+ tzinfo = object ,
888
+ fold = 0 ,
889
+ ):
871
890
"""
872
891
implements datetime.replace, handles nanoseconds.
873
892
@@ -910,8 +929,9 @@ default 'raise'
910
929
def validate (k , v ):
911
930
""" validate integers """
912
931
if not is_integer_object(v):
913
- raise ValueError (f" value must be an integer, received "
914
- f" {type(v)} for {k}" )
932
+ raise ValueError (
933
+ f" value must be an integer, received {type(v)} for {k}"
934
+ )
915
935
return v
916
936
917
937
if year is not None :
0 commit comments