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

E1101: Instance of 'WSGIRequest' has no 'rendered_content' member (no-member) #332

Open
d33tah opened this issue Aug 12, 2021 · 3 comments

Comments

@d33tah
Copy link

d33tah commented Aug 12, 2021

Looks like I managed to reproduce bug #78

pip freeze contents

asgiref==3.4.1
astroid==2.6.6
Django==3.2.6
isort==5.9.3
lazy-object-proxy==1.6.0
mccabe==0.6.1
pylint==2.9.6
pylint-django==2.4.4
pylint-plugin-utils==0.6
pytz==2021.1
sqlparse==0.4.1
toml==0.10.2
wrapt==1.12.1

offending code

from django.test import SimpleTestCase
from django.test import TransactionTestCase


class GrandparentOfSecondClass(TransactionTestCase):

    def get(self):
        return self.client.get("/some/example")


class ParentOfSecondClass(GrandparentOfSecondClass):
    pass


class ThirdBaseClass(ParentOfSecondClass):
    pass


class SecondBaseClass(ParentOfSecondClass):
    pass


class ParentOfGrandparentOfSecondClass(SimpleTestCase):
    pass


class FirstBaseClass(ParentOfGrandparentOfSecondClass):
    pass


class BuggyTestCase(
    FirstBaseClass,
    SecondBaseClass,
    ThirdBaseClass
):

    def test_example(self):
        resp = self.get()
        self.assertEqual(resp.rendered_content, "")

Link to repository

In order to make the bug easy to reproduce, here's a repo with a dockerfile:

https://github.com/d33tah/bug-repro-pylint-django-issue78

@amuuname
Copy link

I am having similar problem with WSGIRequest has no data and status_code members.
WARNING: Please do not report issues about missing Django, see
README!

TODO: make sure to post the output of pip freeze

NOTES: make sure you have the latest version of 3rd party packages
like rest_framework, factory, model_utils, etc. before reporting
issues!

Output from pip freeze

asgiref==3.4.1
astroid==2.9.3
certifi==2021.10.8
charset-normalizer==2.0.10
coreapi==2.3.3
coreschema==0.0.4
Django==4.0.1
django-stubs==1.9.0
django-stubs-ext==0.3.1
djangorestframework-stubs==1.4.0
greenlet==1.1.2
idna==3.3
isort==5.10.1
itypes==1.2.0
Jinja2==3.0.3
lazy-object-proxy==1.7.1
MarkupSafe==2.0.1
mccabe==0.6.1
msgpack==1.0.3
mypy==0.931
mypy-extensions==0.4.3
platformdirs==2.4.1
pylint==2.12.2
pylint-django==2.5.0
pylint-plugin-utils==0.7
pynvim==0.4.3
requests==2.27.1
six==1.16.0
sqlparse==0.4.2
toml==0.10.2
tomli==2.0.0
types-pytz==2021.3.4
types-PyYAML==6.0.3
typing_extensions==4.0.1
uritemplate==4.1.1
urllib3==1.26.8
wrapt==1.13.3

Test file for django

from django.urls import reverse
from rest_framework.test import APITestCase
from rest_framework import status

class TestDemo(APITestCase):
    def test_demo(self):
        response = self.cilent.get(reverse("some_url"))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data["foo"], "bar")

Above code produces below errors:

E1101: Instance of 'WSGIRequest' has no 'status_code' member (no-member)
E1101: Instance of 'WSGIRequest' has no 'data' member (no-member)

@XF-FW
Copy link

XF-FW commented Mar 28, 2022

Just to add to this issue information, as I've encountered something similar.

If I use response.data just once, everything works fine. If I use it more than once, then: E1101: Instance of 'WSGIRequest' has no 'data' member (no-member).

My current workaround, which works fine atm is to simply assign response.data to response_data.

For reference, I think these are the relevant packages and their respective versions:

pylint==2.12.2
pylint-django==2.5.2
django==4.0.3

XF-FW added a commit to XF-FW/pylint-django that referenced this issue Mar 29, 2022
Fixes pylint-dev#332 

Supresses "no-member" for attributes of a WSGIRequest, that is inside a class that inherits from django.test.testcases.SimpleTestCase.

Let me know if you need me to change anything.
Thank you.
@XF-FW
Copy link

XF-FW commented May 28, 2022

I can no longer reproduce this issue.

pylint==2.13.9
pylint-django==2.5.3
django==4.0.4

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

Successfully merging a pull request may close this issue.

3 participants