Skip to content
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

eq-without-hash check removed #5025

Closed
jolaf opened this issue Sep 17, 2021 · 9 comments · Fixed by #5843
Closed

eq-without-hash check removed #5025

jolaf opened this issue Sep 17, 2021 · 9 comments · Fixed by #5843
Assignees
Milestone

Comments

@jolaf
Copy link

jolaf commented Sep 17, 2021

Bug description

class A:
    def __init__(self) -> None:
        self.x = 5

    def __eq__(self, other: object) -> bool:
        return isinstance(other, A) and other.x == self.x

Configuration

No response

Command used

pylint test.py

Pylint output

empty

Expected behavior

Formerly eq-without-hash error was issued, but no more since pylint 2.11.

Pylint version

pylint 2.11.1
astroid 2.8.0
Python 3.8.10 (default, Jun  2 2021, 10:49:15) 
[GCC 9.4.0]

OS / Environment

Ubuntu 20.04.3 LTS \n \l

Additional dependencies

No response

@jolaf jolaf added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 17, 2021
@cdce8p
Copy link
Member

cdce8p commented Sep 17, 2021

The warning was removed as part of #4942.
@Pierre-Sassoulas What do you think? Maybe this should be added back as an optional checker?

https://docs.python.org/3/reference/datamodel.html#object.__hash__

@jolaf
Copy link
Author

jolaf commented Sep 17, 2021

I saw #4942, but in Python 3, automatic reset of __hash__ to None if __eq__ is defined is non-trivial behavior that may cause hard-to-catch bugs.
I think its pretty reasonable to have a capability to warn about such things.
Even more so as this check was already present.
In other words, from my point of view, this check is usable even in strictly Python 3 context.

I didn't check, but I suspect some other checks that were introduced for checking the correctness of porting, and are now removed, are in fact pretty useful in Python 3-only code too.

@cdce8p
Copy link
Member

cdce8p commented Sep 17, 2021

@jolaf I went looked through the list twice, once for the review and the second time for your issue. eq-without-hash is the only one I know about now, all others seem to check for Python 2 behavior that isn't possible in Python 3. Tbh I haven't used Python 2, so it might be possible that I missed others. You can find the list here:
https://github.com/PyCQA/pylint/pull/4942/files#diff-34a57926d10bd84d60b6ddceb5447be233469d5e4e097ce7e5ecd64287fc5899L188-L608

Keep in mind that all of them had been disabled by default already. Your issue is the first one we've gotten about this.

@jolaf
Copy link
Author

jolaf commented Sep 18, 2021

@cdce8p Yeah, I think you're right.
I've now also checked the list (thanks for the clear link) and found no other cases raising suspicions.

@Pierre-Sassoulas
Copy link
Member

Let's move that to an existing checker, I think it could even be a default check ? Thank you for pointing that out @jolaf I did not use it myself as everything in the python3 porting checker was disabled by default.

@Pierre-Sassoulas Pierre-Sassoulas added Regression and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 18, 2021
@Pierre-Sassoulas Pierre-Sassoulas self-assigned this Sep 19, 2021
@Pierre-Sassoulas Pierre-Sassoulas changed the title eq-without-hash check removed eq-without-hash check removed Feb 26, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Feb 26, 2022
Pierre-Sassoulas added a commit that referenced this issue Mar 8, 2022
* Reinstate checks from the python3 checker that are still useful for py3

Closes #5025

Co-authored-by: Daniël van Noord <[email protected]>
@ghpqans
Copy link

ghpqans commented Dec 7, 2022

Why is this and other options still present in the documentation for pylint 2.16 if it became deprecated since 2.11?
https://pylint.pycqa.org/en/latest/user_guide/messages/warning/eq-without-hash.html

Please reopen the issue. Seems like a documentation bug.

@Pierre-Sassoulas
Copy link
Member

It was restored in #5843 following this very issue that argue for it to be reinstated.

@ghpqans
Copy link

ghpqans commented Dec 8, 2022

Seems to be still present in the pypi package repo, from where I installed pylint:

(venv) user@l-user:~/PycharmProjects/my_project$ pylint --version
pylint 2.15.5
[...]
.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-operator-function' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942. (useless-option-value)
.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-urllib-function' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942. (useless-option-value)
.pylintrc:1:0: R0022: Useless option value for '--disable', 'xreadlines-attribute' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942. (useless-option-value)
.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-sys-function' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942. (useless-option-value)
.pylintrc:1:0: R0022: Useless option value for '--disable', 'exception-escape' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942. (useless-option-value)
.pylintrc:1:0: R0022: Useless option value for '--disable', 'comprehension-escape' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942. (useless-option-value)
.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'long-suffix' (unknown-option-value)
.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'old-ne-operator' (unknown-option-value)
.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'old-octal-literal' (unknown-option-value)
.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'non-ascii-bytes-literal' (unknown-option-value)
!---->> .pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'eq-without-hash' (unknown-option-value)

@Pierre-Sassoulas
Copy link
Member

You need to activate the corresponding extension now, see notes from the link you pasted:

This message is emitted by the optional 'eq-without-hash' checker which requires the pylint.extensions.eq_without_hash plugin to be loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants