Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

STY: ignore mypy errors #62482

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

Open
Alvaro-Kothe wants to merge 4 commits into pandas-dev:main
base: main
Choose a base branch
Loading
from Alvaro-Kothe:fix/mypy-errors

Conversation

Copy link
Contributor

@Alvaro-Kothe Alvaro-Kothe commented Sep 27, 2025
edited
Loading

I think this will make the CI green again.

The errors are because of a new version of numpy:

+ numpy==2.3.3
- numpy==2.2.6
+ numpy-typing-compat==20250818.2.3
- numpy-typing-compat==20250818.2.2
Original errors
# mypy
pandas/core/arrays/arrow/_arrow_utils.py:47: error: Unused "type: ignore" comment [unused-ignore]
pandas/_typing.py:87: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/util/hashing.py:327: error: Incompatible types in assignment (expression has type "CategoricalDtype", variable has type "dtype[Any]") [assignment]
pandas/core/util/hashing.py:328: error: Argument 2 to "_simple_new" of "Categorical" has incompatible type "dtype[Any]"; expected "CategoricalDtype" [arg-type]
pandas/core/nanops.py:656: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/array_algos/quantile.py:105: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/algorithms.py:223: error: Incompatible types in assignment (expression has type "ndarray[tuple[Any, ...], dtype[Any]]", variable has type "ExtensionArray") [assignment]
pandas/core/arrays/datetimes.py:807: error: Argument 1 to "view" of "ndarray" has incompatible type "dtype[datetime64[date | int | None]] | DatetimeTZDtype"; expected "dtype[Any] | _HasDType[dtype[Any]]" [arg-type]
pandas/core/arrays/_mixins.py:154: error: Argument "dtype" to "view" of "ndarray" has incompatible type "ExtensionDtype | dtype[Any]"; expected "dtype[Any] | _HasDType[dtype[Any]]" [arg-type]
pandas/core/arrays/string_.py:767: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/arrays/arrow/array.py:660: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/arrays/arrow/array.py:2741: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/arrays/categorical.py:1872: error: Unused "type: ignore" comment [unused-ignore]
pandas/io/pytables.py:3309: error: Unused "type: ignore" comment [unused-ignore]
pandas/io/pytables.py:3309: error: "ExtensionArray" has no attribute "asi8" [attr-defined]
pandas/io/pytables.py:3309: note: Error code "attr-defined" not covered by "type: ignore" comment
pandas/io/pytables.py:3315: error: Unused "type: ignore" comment [unused-ignore]
pandas/io/pytables.py:3315: error: "ExtensionArray" has no attribute "tz" [attr-defined]
pandas/io/pytables.py:3315: note: Error code "attr-defined" not covered by "type: ignore" comment
pandas/io/pytables.py:5199: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/reshape/merge.py:1749: error: Item "ExtensionArray" of "ExtensionArray | Any" has no attribute "all" [union-attr]
pandas/core/reshape/merge.py:1769: error: Item "ExtensionArray" of "ExtensionArray | Any" has no attribute "all" [union-attr]
pandas/core/reshape/encoding.py:362: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/indexers/objects.py:134: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/indexers/objects.py:135: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/indexers/objects.py:405: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/indexers/objects.py:491: error: Unused "type: ignore" comment [unused-ignore]
pandas/core/groupby/groupby.py:1889: error: Unused "type: ignore" comment [unused-ignore]
# pyright
 pandas/core/methods/describe.py:357:19 - error: Type "list[float | NDArray[Any]]" is not assignable to declared type "Sequence[float] | ndarray[_AnyShape, dtype[Any]] | None"
  Type "list[float | NDArray[Any]]" is not assignable to type "Sequence[float] | ndarray[_AnyShape, dtype[Any]] | None"
   "list[float | NDArray[Any]]" is not assignable to "Sequence[float]"
    Type parameter "_T_co@Sequence" is covariant, but "float | NDArray[Any]" is not a subtype of "float"
     Type "float | NDArray[Any]" is not assignable to type "float"
      "ndarray[_AnyShape, dtype[Any]]" is not assignable to "float"
   "list[float | NDArray[Any]]" is not assignable to "ndarray[_AnyShape, dtype[Any]]"
   "list[float | NDArray[Any]]" is not assignable to "None" (reportAssignmentType)
   
 pandas/core/methods/describe.py:360:25 - error: Argument of type "Sequence[float] | ndarray[_AnyShape, dtype[Any]] | None" cannot be assigned to parameter "q" of type "float | Iterable[float]" in function "validate_percentile"
  Type "Sequence[float] | ndarray[_AnyShape, dtype[Any]] | None" is not assignable to type "float | Iterable[float]"
   Type "None" is not assignable to type "float | Iterable[float]"
    "None" is not assignable to "float"
    "None" is incompatible with protocol "Iterable[float]"
     "__iter__" is not present (reportArgumentType)

Copy link
Contributor

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. When we have mypy errors, we try to include text of the mypy error in a comment, so there is a few places where you need to add those.

td64_values = arr.view(dtype)
return TimedeltaArray._simple_new(td64_values, dtype=dtype)
return arr.view(dtype=dtype)
return arr.view(dtype=dtype)# type: ignore[arg-type]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add mypy error in comment

res_values = offset._apply_array(values._ndarray)
if res_values.dtype.kind == "i":
res_values = res_values.view(values.dtype)
res_values = res_values.view(values.dtype)# type: ignore[arg-type]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add mypy error in comment

mask = ~np.isnan(lk)
match = lk == casted
if not match[mask].all():
if not match[mask].all():# type: ignore[union-attr]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add mypy error in comment

mask = ~np.isnan(rk)
match = rk == casted
if not match[mask].all():
if not match[mask].all():# type: ignore[union-attr]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add mypy error in comment

Comment on lines +3309 to +3315
value.asi8, # type: ignore[attr-defined]
)

node = getattr(self.group, key)
# error: Item "ExtensionArray" of "Union[Any, ExtensionArray]" has no
# attribute "tz"
node._v_attrs.tz = _get_tz(value.tz) # type: ignore[union-attr]
node._v_attrs.tz = _get_tz(value.tz) # type: ignore[attr-defined]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add mypy error in comments (both places)

Comment on lines 220 to 225
values = cls._from_sequence(values, dtype=dtype) # type: ignore[assignment]

else:
values = values.astype(dtype, copy=False)
values = values.astype(dtype, copy=False)# type: ignore[assignment]

return values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be fixed as follows. (and you can remove the comments in 218-219). Move the return values statement after line 220 where it says values = cls.from_sequence ... and after line 223 the values = values.astype... statement so that it is no longer at the end of the function.

If mypy still complains on either statement, you need to have a comment in there with the mypy error (as in lines 218-219)

Comment on lines 654 to +656
# error: Unsupported target for indexed assignment ("Union[ndarray[Any, Any],
# datetime64, timedelta64]")
result[axis_mask] = iNaT# type: ignore[index]
result[axis_mask] = iNaT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the comment here since you removed the ignore

Co-authored-by: Irv Lustig <irv@princeton.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Dr-Irv Dr-Irv Dr-Irv requested changes

@rhshadrach rhshadrach Awaiting requested review from rhshadrach rhshadrach is a code owner

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /