@@ -811,15 +811,15 @@ def test_constructor_dtype_datetime64(self):
811811 expected = Series (values2 , index = dates )
812812
813813 for dtype in ["s" , "D" , "ms" , "us" , "ns" ]:
814- values1 = dates .view (np .ndarray ).astype ("M8[{0 }]" . format ( dtype ) )
814+ values1 = dates .view (np .ndarray ).astype (f "M8[{ dtype } ]" )
815815 result = Series (values1 , dates )
816816 tm .assert_series_equal (result , expected )
817817
818818 # GH 13876
819819 # coerce to non-ns to object properly
820820 expected = Series (values2 , index = dates , dtype = object )
821821 for dtype in ["s" , "D" , "ms" , "us" , "ns" ]:
822- values1 = dates .view (np .ndarray ).astype ("M8[{0 }]" . format ( dtype ) )
822+ values1 = dates .view (np .ndarray ).astype (f "M8[{ dtype } ]" )
823823 result = Series (values1 , index = dates , dtype = object )
824824 tm .assert_series_equal (result , expected )
825825
@@ -952,7 +952,7 @@ def test_constructor_with_datetime_tz(self):
952952 def test_construction_to_datetimelike_unit (self , arr_dtype , dtype , unit ):
953953 # tests all units
954954 # gh-19223
955- dtype = "{ }[{}]". format ( dtype , unit )
955+ dtype = f" { dtype } [{ unit } ]"
956956 arr = np .array ([1 , 2 , 3 ], dtype = arr_dtype )
957957 s = Series (arr )
958958 result = s .astype (dtype )
@@ -1347,12 +1347,11 @@ def test_convert_non_ns(self):
13471347 def test_constructor_cant_cast_datetimelike (self , index ):
13481348
13491349 # floats are not ok
1350- msg = "Cannot cast {}.*? to " .format (
1351- # strip Index to convert PeriodIndex -> Period
1352- # We don't care whether the error message says
1353- # PeriodIndex or PeriodArray
1354- type (index ).__name__ .rstrip ("Index" )
1355- )
1350+ # strip Index to convert PeriodIndex -> Period
1351+ # We don't care whether the error message says
1352+ # PeriodIndex or PeriodArray
1353+ msg = f"Cannot cast { type (index ).__name__ .rstrip ('Index' )} .*? to "
1354+
13561355 with pytest .raises (TypeError , match = msg ):
13571356 Series (index , dtype = float )
13581357
0 commit comments