@@ -256,7 +256,7 @@ def _scalar_type(self) -> type[Timestamp]:
256
256
_freq = None
257
257
258
258
def __init__ (
259
- self , values , dtype = DT64NS_DTYPE , freq = lib .no_default , copy : bool = False
259
+ self , values , dtype = None , freq = lib .no_default , copy : bool = False
260
260
) -> None :
261
261
values = extract_array (values , extract_numpy = True )
262
262
if isinstance (values , IntegerArray ):
@@ -276,22 +276,19 @@ def __init__(
276
276
freq = to_offset (freq )
277
277
freq , _ = dtl .validate_inferred_freq (freq , values .freq , False )
278
278
279
- # validation
280
- dtz = getattr (dtype , "tz" , None )
281
- if dtz and values .tz is None :
282
- dtype = DatetimeTZDtype (tz = dtype .tz )
283
- elif dtz and values .tz :
284
- if not timezones .tz_compare (dtz , values .tz ):
285
- msg = (
286
- "Timezone of the array and 'dtype' do not match. "
287
- f"'{ dtz } ' != '{ values .tz } '"
279
+ if dtype is not None :
280
+ dtype = pandas_dtype (dtype )
281
+ if not is_dtype_equal (dtype , values .dtype ):
282
+ raise TypeError (
283
+ f"dtype={ dtype } does not match data dtype { values .dtype } "
288
284
)
289
- raise TypeError (msg )
290
- elif values .tz :
291
- dtype = values .dtype
292
285
286
+ dtype = values .dtype
293
287
values = values ._ndarray
294
288
289
+ elif dtype is None :
290
+ dtype = DT64NS_DTYPE
291
+
295
292
if not isinstance (values , np .ndarray ):
296
293
raise ValueError (
297
294
f"Unexpected type '{ type (values ).__name__ } '. 'values' must be a "
0 commit comments