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 (no-member) on functions when typing foreig key fields #402

Open
dpinol opened this issue Jul 21, 2023 · 0 comments
Open

E1101 (no-member) on functions when typing foreig key fields #402

dpinol opened this issue Jul 21, 2023 · 0 comments

Comments

@dpinol
Copy link

dpinol commented Jul 21, 2023

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

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

No branches or pull requests

1 participant