Skip to content

CLN: use standard method to set unhashable object #36717

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 3 commits into from

Conversation

fangchenli
Copy link
Member

@fangchenli fangchenli commented Sep 28, 2020

#20589 mentioned lgtm. So I decided to test it. And it found this potential improvement. There is even a detailed reference with code examples. https://lgtm.com/rules/1780095/ Very interesting.

Just trying to see if their suggestion works.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm

f"{repr(type(self).__name__)} objects are mutable, "
f"thus they cannot be hashed"
)
__hash__ = None
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment / ref for this

@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Sep 30, 2020
@jreback jreback added this to the 1.2 milestone Sep 30, 2020
@jreback
Copy link
Contributor

jreback commented Sep 30, 2020

ci checks is failing as well

@fangchenli
Copy link
Member Author

ci checks is failing as well

pandas/core/generic.py:1767: error: Incompatible types in assignment (expression has type "None", base class "object" defined the type as "Callable[[object], int]") [assignment]

If hash=None is the desired way to indicate unhashable object, this could be a mypy issue.

@fangchenli
Copy link
Member Author

xref python/mypy#4266

@fangchenli
Copy link
Member Author

close for now. It doesn't work with mypy.

@fangchenli fangchenli closed this Sep 30, 2020
@fangchenli fangchenli deleted the generic-hash branch October 3, 2020 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants