Skip to content

Commit 931bd29

Browse files
check_untyped_defs pandas.core.dtypes.cast
1 parent bedda72 commit 931bd29

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pandas/core/dtypes/cast.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" routings for casting """
22

33
from datetime import datetime, timedelta
4+
from typing import Union
45

56
import numpy as np
67

@@ -959,7 +960,12 @@ def try_datetime(v):
959960
try:
960961

961962
values, tz = conversion.datetime_to_datetime64(v)
962-
return DatetimeIndex(values).tz_localize("UTC").tz_convert(tz=tz)
963+
# error: "DatetimeIndex" has no attribute "tz_localize"
964+
return (
965+
DatetimeIndex(values) # type: ignore
966+
.tz_localize("UTC")
967+
.tz_convert(tz=tz)
968+
)
963969
except (ValueError, TypeError):
964970
pass
965971

@@ -1237,6 +1243,7 @@ def construct_1d_arraylike_from_scalar(value, length, dtype):
12371243
np.ndarray / pandas type of length, filled with value
12381244
12391245
"""
1246+
subarr: Union["DatetimeIndex", "Categorical", np.ndarray]
12401247
if is_datetime64tz_dtype(dtype):
12411248
from pandas import DatetimeIndex
12421249

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ check_untyped_defs=False
194194
[mypy-pandas.core.computation.pytables]
195195
check_untyped_defs=False
196196

197-
[mypy-pandas.core.dtypes.cast]
198-
check_untyped_defs=False
199-
200197
[mypy-pandas.core.frame]
201198
check_untyped_defs=False
202199

0 commit comments

Comments
 (0)