Skip to content

CLN/TYP: redundant casts and unused ignores #33453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3838,7 +3838,7 @@ def values(self) -> np.ndarray:
return self._data.view(np.ndarray)

@cache_readonly
@doc(IndexOpsMixin.array) # type: ignore
@doc(IndexOpsMixin.array)
def array(self) -> ExtensionArray:
array = self._data
if isinstance(array, np.ndarray):
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/json/_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _pull_field(
js: Dict[str, Any], spec: Union[List, str]
) -> Union[Scalar, Iterable]:
"""Internal function to pull field"""
result = js # type: ignore
result = js
if isinstance(spec, list):
for field in spec:
result = result[field]
Expand All @@ -251,7 +251,7 @@ def _pull_records(js: Dict[str, Any], spec: Union[List, str]) -> Iterable:
# null, otherwise return an empty list
if not isinstance(result, Iterable):
if pd.isnull(result):
result = [] # type: ignore
result = []
else:
raise TypeError(
f"{js} has non iterable value {result} for path {spec}. "
Expand Down
4 changes: 1 addition & 3 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1916,9 +1916,7 @@ def is_indexed(self) -> bool:
if not hasattr(self.table, "cols"):
# e.g. if infer hasn't been called yet, self.table will be None.
return False
# GH#29692 mypy doesn't recognize self.table as having a "cols" attribute
# 'error: "None" has no attribute "cols"'
return getattr(self.table.cols, self.cname).is_indexed # type: ignore
return getattr(self.table.cols, self.cname).is_indexed

def convert(self, values: np.ndarray, nan_rep, encoding: str, errors: str):
"""
Expand Down
5 changes: 2 additions & 3 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,9 @@ def parse_dates_safe(dates, delta=False, year=False, days=False):
time_delta = dates - stata_epoch
d["delta"] = time_delta._values.astype(np.int64) // 1000 # microseconds
if days or year:
# ignore since mypy reports that DatetimeIndex has no year/month
date_index = DatetimeIndex(dates)
d["year"] = date_index.year # type: ignore
d["month"] = date_index.month # type: ignore
d["year"] = date_index.year
d["month"] = date_index.month
if days:
days_in_ns = dates.astype(np.int64) - to_datetime(
d["year"], format="%Y"
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ ignore_missing_imports=True
no_implicit_optional=True
check_untyped_defs=True
strict_equality=True
warn_redundant_casts = True
warn_unused_ignores = True

[mypy-pandas.tests.*]
check_untyped_defs=False
Expand Down