Skip to content

Commit fbae09e

Browse files
CLN/TYP: redundant casts and unused ignores (#33453)
1 parent 78d8af1 commit fbae09e

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3838,7 +3838,7 @@ def values(self) -> np.ndarray:
38383838
return self._data.view(np.ndarray)
38393839

38403840
@cache_readonly
3841-
@doc(IndexOpsMixin.array) # type: ignore
3841+
@doc(IndexOpsMixin.array)
38423842
def array(self) -> ExtensionArray:
38433843
array = self._data
38443844
if isinstance(array, np.ndarray):

pandas/io/json/_normalize.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def _pull_field(
231231
js: Dict[str, Any], spec: Union[List, str]
232232
) -> Union[Scalar, Iterable]:
233233
"""Internal function to pull field"""
234-
result = js # type: ignore
234+
result = js
235235
if isinstance(spec, list):
236236
for field in spec:
237237
result = result[field]
@@ -251,7 +251,7 @@ def _pull_records(js: Dict[str, Any], spec: Union[List, str]) -> Iterable:
251251
# null, otherwise return an empty list
252252
if not isinstance(result, Iterable):
253253
if pd.isnull(result):
254-
result = [] # type: ignore
254+
result = []
255255
else:
256256
raise TypeError(
257257
f"{js} has non iterable value {result} for path {spec}. "

pandas/io/pytables.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1916,9 +1916,7 @@ def is_indexed(self) -> bool:
19161916
if not hasattr(self.table, "cols"):
19171917
# e.g. if infer hasn't been called yet, self.table will be None.
19181918
return False
1919-
# GH#29692 mypy doesn't recognize self.table as having a "cols" attribute
1920-
# 'error: "None" has no attribute "cols"'
1921-
return getattr(self.table.cols, self.cname).is_indexed # type: ignore
1919+
return getattr(self.table.cols, self.cname).is_indexed
19221920

19231921
def convert(self, values: np.ndarray, nan_rep, encoding: str, errors: str):
19241922
"""

pandas/io/stata.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,9 @@ def parse_dates_safe(dates, delta=False, year=False, days=False):
356356
time_delta = dates - stata_epoch
357357
d["delta"] = time_delta._values.astype(np.int64) // 1000 # microseconds
358358
if days or year:
359-
# ignore since mypy reports that DatetimeIndex has no year/month
360359
date_index = DatetimeIndex(dates)
361-
d["year"] = date_index.year # type: ignore
362-
d["month"] = date_index.month # type: ignore
360+
d["year"] = date_index.year
361+
d["month"] = date_index.month
363362
if days:
364363
days_in_ns = dates.astype(np.int64) - to_datetime(
365364
d["year"], format="%Y"

setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ ignore_missing_imports=True
126126
no_implicit_optional=True
127127
check_untyped_defs=True
128128
strict_equality=True
129+
warn_redundant_casts = True
130+
warn_unused_ignores = True
129131

130132
[mypy-pandas.tests.*]
131133
check_untyped_defs=False

0 commit comments

Comments
 (0)