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

False positive: E1130 on double unary operator #8597

Closed
bastian-wattro opened this issue Apr 20, 2023 · 1 comment
Closed

False positive: E1130 on double unary operator #8597

bastian-wattro opened this issue Apr 20, 2023 · 1 comment
Labels
Astroid Related to astroid Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@bastian-wattro
Copy link

bastian-wattro commented Apr 20, 2023

Bug description

Since 2.17.2 Pylint does not accept using a double negation on django Q objects:

(Reproduced in a venv using Python 3.10.10 with nothing but pylint and django installed)

"""Bug reproduction: false positive E1130"""
from django.db.models import Q

def false_positive(need_text=False) -> Q:
    """note the double negation"""
    has_text = ~Q(text="")
    if need_text:
        return has_text
    return ~has_text # E1130: bad operand type for unary ~: Node (invalid-unary-operand-type)

def this_is_ok(need_text=False) -> Q:
    """no double negation here"""
    has_no_text = Q(text="")
    if need_text:
        return ~has_no_text
    return has_no_text

Configuration

No response

Command used

$ pylint reproduce.py

Pylint output

************* Module reproduce
reproduce.py:9:11: E1130: bad operand type for unary ~: Node (invalid-unary-operand-type)

Expected behavior

Same behaviour as in v2.17.1 (no error)

Pylint version

2.17.2

OS / Environment

$ uname --kernel-release
5.10.174-1-MANJARO

Additional dependencies

No response

@bastian-wattro bastian-wattro added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 20, 2023
@DanielNoord DanielNoord added Astroid Related to astroid Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 21, 2023
@DanielNoord
Copy link
Collaborator

Have you reported this against https://github.com/PyCQA/pylint-django? Or are you not using it? If it is the latter, please consider doing so.

Going to close this for now as we have explicitly put support for django in a separate plugin and repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Astroid Related to astroid Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

2 participants