pylint-django
pylint-django copied to clipboard
E1101 (no-member) on functions when typing foreig key fields
from __future__ import annotations
from django.db import models
class Author(models.Model):
name: str = models.CharField(max_length=200)
def func(self) -> str:
return self.name
class Book(models.Model):
author: Author = models.ForeignKey(Author, on_delete=models.CASCADE)
def author_name(self):
print(self.author.name)
return self.author.func()
I get this error
15: E1101: Instance of 'ForeignKey' has no 'func' member (no-member)
Be aware that there are type hints in the model foreign key fields so that my IDE can recognize the instance field types.
Curiously pylint complains about the function func but not about the field name
pylint==2.17.4
astroid==2.15.5
Python 3.11.3
thanks
Same issue here