Skip to content

TYP: activate Check for missing error codes #36088

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
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
7 changes: 3 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,9 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
invgrep -R --include="*.py" -P '# type: (?!ignore)' pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

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

MSG='Check for use of foo.__class__ instead of type(foo)' ; echo $MSG
invgrep -R --include=*.{py,pyx} '\.__class__' pandas
Expand Down
5 changes: 2 additions & 3 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,9 @@ def _ndarray(self) -> np.ndarray:

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

# ------------------------------------------------------------------

Expand Down
6 changes: 4 additions & 2 deletions pandas/core/groupby/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ def recode_from_groupby(
"""
# we re-order to the original category orderings
if sort:
return ci.set_categories(c.categories) # type: ignore [attr-defined]
# error: "CategoricalIndex" has no attribute "set_categories"
return ci.set_categories(c.categories) # type: ignore[attr-defined]

# we are not sorting, so add unobserved to the end
new_cats = c.categories[~c.categories.isin(ci.categories)]
return ci.add_categories(new_cats) # type: ignore [attr-defined]
# error: "CategoricalIndex" has no attribute "add_categories"
return ci.add_categories(new_cats) # type: ignore[attr-defined]
6 changes: 5 additions & 1 deletion pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ def get_compression_method(
if isinstance(compression, Mapping):
compression_args = dict(compression)
try:
compression_method = compression_args.pop("method") # type: ignore
# error: Incompatible types in assignment (expression has type
# "Union[str, int, None]", variable has type "Optional[str]")
compression_method = compression_args.pop( # type: ignore[assignment]
"method"
)
except KeyError as err:
raise ValueError("If mapping, compression must have key 'method'") from err
else:
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def _plot(cls, ax: "Axes", x, y, style=None, is_errorbar: bool = False, **kwds):
if style is not None:
args = (x, y, style)
else:
args = (x, y) # type:ignore[assignment]
args = (x, y) # type: ignore[assignment]
return ax.plot(*args, **kwds)

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