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

DjangoRestFramework: E1131: unsupported operand type(s) for | (unsupported-binary-operation) #4951

Closed
rvanlaar opened this issue Sep 1, 2021 · 0 comments · Fixed by #6664
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@rvanlaar
Copy link

rvanlaar commented Sep 1, 2021

Bug description

# pylint: disable=missing-docstring

from rest_framework.permissions import BasePermission, IsAuthenticated, SAFE_METHODS

class ReadOnly(BasePermission):
    def has_permission(self, request, view):
        return request.method in SAFE_METHODS

permission_classes = [IsAuthenticated|ReadOnly]

Configuration

No response

Command used

pylint binary.py

Pylint output

************* Module binary
binary.py:9:22: E1131: unsupported operand type(s) for | (unsupported-binary-operation)

-----------------------------------
Your code has been rated at 0.00/10

Expected behavior

For pylint to not throw this error.

Django Rest Framework supports binary operands for permissions [1]
This example code is taken from the documentation [2]
[1] https://github.com/encode/django-rest-framework/blob/master/rest_framework/permissions.py
[2] https://www.django-rest-framework.org/api-guide/permissions/

Pylint version

pylint 2.10.2
astroid 2.7.3
Python 3.9.4 (default, Apr 10 2021,

OS / Environment

Debian GNU/Linux 10 (buster)

Additional dependencies

djangorestframework==3.12.4

edit: Added link [2] to django rest frameworks documentation on permissions

@rvanlaar rvanlaar added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 1, 2021
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 1, 2021
@DanielNoord DanielNoord self-assigned this Dec 7, 2021
@DanielNoord DanielNoord modified the milestones: 2.13.x, 2.13.0 Dec 7, 2021
@DanielNoord DanielNoord removed their assignment Dec 13, 2021
@DanielNoord DanielNoord removed this from the 2.13.0 milestone Dec 13, 2021
timmartin added a commit to timmartin/pylint that referenced this issue May 22, 2022
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.14.0, 2.15.0 May 29, 2022
Pierre-Sassoulas pushed a commit that referenced this issue Jun 23, 2022
* Use consistent location for NotFoundError

Throughout this module we're using ``astroid.NotFoundError`` as an
alias for ``astroid.exceptions.NotFoundError``, it seems best to be
consistent.

Closes #4951

Co-authored-by: Jacob Walls <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants