Skip to content

Commit 6016b17

Browse files
TYP: activate Check for missing error codes (#36088)
1 parent 3ca6d8f commit 6016b17

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

ci/code_checks.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,9 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
230230
invgrep -R --include="*.py" -P '# type: (?!ignore)' pandas
231231
RET=$(($RET + $?)) ; echo $MSG "DONE"
232232

233-
# https://github.com/python/mypy/issues/7384
234-
# MSG='Check for missing error codes with # type: ignore' ; echo $MSG
235-
# invgrep -R --include="*.py" -P '# type: ignore(?!\[)' pandas
236-
# RET=$(($RET + $?)) ; echo $MSG "DONE"
233+
MSG='Check for missing error codes with # type: ignore' ; echo $MSG
234+
invgrep -R --include="*.py" -P '# type:\s?ignore(?!\[)' pandas
235+
RET=$(($RET + $?)) ; echo $MSG "DONE"
237236

238237
MSG='Check for use of foo.__class__ instead of type(foo)' ; echo $MSG
239238
invgrep -R --include=*.{py,pyx} '\.__class__' pandas

pandas/core/arrays/datetimelike.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,9 @@ def _ndarray(self) -> np.ndarray:
468468

469469
def _from_backing_data(self: _T, arr: np.ndarray) -> _T:
470470
# Note: we do not retain `freq`
471+
# error: Too many arguments for "NDArrayBackedExtensionArray"
471472
# error: Unexpected keyword argument "dtype" for "NDArrayBackedExtensionArray"
472-
# TODO: add my error code
473-
# https://github.com/python/mypy/issues/7384
474-
return type(self)(arr, dtype=self.dtype) # type: ignore
473+
return type(self)(arr, dtype=self.dtype) # type: ignore[call-arg]
475474

476475
# ------------------------------------------------------------------
477476

pandas/core/groupby/categorical.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ def recode_from_groupby(
9898
"""
9999
# we re-order to the original category orderings
100100
if sort:
101-
return ci.set_categories(c.categories) # type: ignore [attr-defined]
101+
# error: "CategoricalIndex" has no attribute "set_categories"
102+
return ci.set_categories(c.categories) # type: ignore[attr-defined]
102103

103104
# we are not sorting, so add unobserved to the end
104105
new_cats = c.categories[~c.categories.isin(ci.categories)]
105-
return ci.add_categories(new_cats) # type: ignore [attr-defined]
106+
# error: "CategoricalIndex" has no attribute "add_categories"
107+
return ci.add_categories(new_cats) # type: ignore[attr-defined]

pandas/io/common.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ def get_compression_method(
374374
if isinstance(compression, Mapping):
375375
compression_args = dict(compression)
376376
try:
377-
compression_method = compression_args.pop("method") # type: ignore
377+
# error: Incompatible types in assignment (expression has type
378+
# "Union[str, int, None]", variable has type "Optional[str]")
379+
compression_method = compression_args.pop( # type: ignore[assignment]
380+
"method"
381+
)
378382
except KeyError as err:
379383
raise ValueError("If mapping, compression must have key 'method'") from err
380384
else:

pandas/plotting/_matplotlib/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def _plot(cls, ax: "Axes", x, y, style=None, is_errorbar: bool = False, **kwds):
656656
if style is not None:
657657
args = (x, y, style)
658658
else:
659-
args = (x, y) # type:ignore[assignment]
659+
args = (x, y) # type: ignore[assignment]
660660
return ax.plot(*args, **kwds)
661661

662662
def _get_index_name(self) -> Optional[str]:

0 commit comments

Comments
 (0)