-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
Will the cancelled test be re-run? |
yeah, don't worry about it - I'll take a look later in the week, curious to see if there's a way to avoid having to turn off the warning at all |
@@ -1601,6 +1601,7 @@ def __repr__(self) -> str: | |||
""" | |||
Return a string representation for a particular Series. | |||
""" | |||
# pylint: disable=invalid-repr-returned | |||
repr_params = fmt.get_series_repr_params() | |||
return self.to_string(**repr_params) |
There was a problem hiding this comment.
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?
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.
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 |
@@ -1601,6 +1601,7 @@ def __repr__(self) -> str: | |||
""" | |||
Return a string representation for a particular Series. | |||
""" | |||
# pylint: disable=invalid-repr-returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# pylint: disable=invalid-repr-returned |
🤔 not sure what the issue is - if it's already string, I'd rather not add an unnecessary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a bug in pylint, seems like just the presence of an overload throws it off
from __future__ import annotations
from typing import overload
class Foo:
def __repr__(self) -> str:
return self.foo()
@overload
def foo(self) -> str:
...
def foo(self) -> str:
return 'foo'
I'll report there - marking as draft for now then, once/if we can hear back we can move forwards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vamsi-verma-s , looks good to me pending green!
pylint linked my report to this issue pylint-dev/astroid#1015, which has been open since 2021, so I don't think it'll get addressed anytime soon
Happy to just turn off the check inline then
Thanks @vamsi-verma-s |
…49025) * pyllint: disable invalid-repr-returned in Series.__repr__ * remove invalid-repr-returned from pyproject.toml Co-authored-by: Marco Edward Gorelli <[email protected]>
…49025) * pyllint: disable invalid-repr-returned in Series.__repr__ * remove invalid-repr-returned from pyproject.toml Co-authored-by: Marco Edward Gorelli <[email protected]>
Since the params passed are for getting the repr string. This should not be an issue and
to_string
will return astr