pylint-django
pylint-django copied to clipboard
E1101: Instance of 'WSGIRequest' has no 'rendered_content' member (no-member)
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
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)
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
I can no longer reproduce this issue.
pylint==2.13.9
pylint-django==2.5.3
django==4.0.4