Skip to content

False-negative unneeded-not when using hash function #7688

Open
@Moisan

Description

@Moisan

Bug description

Line of the type not hash(x) == hash(y) does not trigger unneeded-not.

More complete example:

def test_unneeded_not():
    first_string = '123'
    second_string = '456'
    assert not first_string == second_string
    assert not hash(first_string) == hash(second_string)
    assert not int(first_string) == int(second_string)

Configuration

No response

Command used

pylint test.py

Pylint output

************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
test.py:4:11: C0113: Consider changing "not first_string == second_string" to "first_string != second_string" (unneeded-not)
test.py:6:11: C0113: Consider changing "not int(first_string) == int(second_string)" to "int(first_string) != int(second_string)" (unneeded-not)

Expected behavior

To trigger not-unneeded on the assert not hash(first_string) == hash(second_string) line.

Pylint version

pylint 2.15.5
astroid 2.12.12
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:01:00)
[Clang 13.0.1 ]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

False Negative 🦋No message is emitted but something is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid updateNeeds an astroid update (probably a release too) before being mergableWork in progressinference

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions