Skip to content

TYP #37715: Fix mypy errors in accessor.py #50005

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

Closed
wants to merge 6 commits into from
Closed
Changes from 5 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
5 changes: 2 additions & 3 deletions pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,15 @@ def cat(
if sep is None:
sep = ""

data: Series
Copy link
Member

Choose a reason for hiding this comment

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

can you try data: Series | np.ndarray?

Copy link
Member

Choose a reason for hiding this comment

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

You can run mypy locally to check for errors


if isinstance(self._orig, ABCIndex):
data = Series(self._orig, index=self._orig, dtype=self._orig.dtype)
else: # Series
data = self._orig

# concatenate Series/Index with itself if no "others"
if others is None:
# error: Incompatible types in assignment (expression has type
# "ndarray", variable has type "Series")
data = ensure_object(data) # type: ignore[assignment]
na_mask = isna(data)
if na_rep is None and na_mask.any():
return sep.join(data[~na_mask])
Expand Down