Skip to content

pylint: disable invalid-repr-returned in Series.__repr__ #49025

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 4 commits into from
Nov 7, 2022
Merged
Changes from 1 commit
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
1 change: 1 addition & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,7 @@ def __repr__(self) -> str:
"""
Return a string representation for a particular Series.
"""
# pylint: disable=invalid-repr-returned
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
# pylint: disable=invalid-repr-returned

repr_params = fmt.get_series_repr_params()
return self.to_string(**repr_params)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to solve the issue. Should we go for this?

Suggested change
return self.to_string(**repr_params)
return str(self.to_string(**repr_params)) # GH#49025

Also, self.to_string method has a validation to ensure only str values are returned.

pandas/pandas/core/series.py

Lines 1700 to 1709 in 2a0e3fe

# catch contract violations
if not isinstance(result, str):
raise AssertionError(
"result must be of type str, type "
f"of result is {repr(type(result).__name__)}"
)
if buf is None:
return result


Expand Down