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

instance of <subclass> has no <class attribute> member when <class attribute> is first defined with type hint #4219

Closed
radkujawa opened this issue Mar 9, 2021 · 3 comments
Labels
Duplicate 🐫 Duplicate of an already existing issue
Milestone

Comments

@radkujawa
Copy link

Steps to reproduce

Given file a.py:

class A:
    CLASS_VAR: int

    def foo1(self):
        print(self.CLASS_VAR)


class B(A):
    CLASS_VAR = 1

    def foo2(self):
        print(self.CLASS_VAR)

Current behavior

$ pylint a.py
************* Module file
a.py:12: [E1101(no-member), B.foo2] Instance of 'B' has no 'CLASS_VAR' member

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

Expected behavior

B is a class that really really has CLASS_VAR member.

pylint --version output

pylint 2.7.2
astroid 2.5.1
Python 3.7.9 (default, Sep 25 2020, 07:46:23) 
[GCC 8.4.0]
@radkujawa
Copy link
Author

Remarks:

@cdce8p
Copy link
Member

cdce8p commented Mar 9, 2021

This is a duplicate of #3167. The fix is already merged and will be included in the next release.
As for #3131 and #3129, they are unrelated issues that still need to be addressed.

@Pierre-Sassoulas Pierre-Sassoulas added the Duplicate 🐫 Duplicate of an already existing issue label Mar 9, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.7.3 milestone Mar 9, 2021
@radkujawa
Copy link
Author

thank you very much for quick response! It's indeed fixed on master branch, I should have checked that first. Sorry!

sjamgade added a commit to Aiven-Open/rohmu that referenced this issue Feb 16, 2023
sjamgade added a commit to Aiven-Open/rohmu that referenced this issue Feb 16, 2023
sjamgade added a commit to Aiven-Open/rohmu that referenced this issue Feb 16, 2023
sjamgade added a commit to Aiven-Open/rohmu that referenced this issue Feb 17, 2023
sjamgade added a commit to Aiven-Open/rohmu that referenced this issue Feb 17, 2023
sjamgade added a commit to Aiven-Open/rohmu that referenced this issue Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

3 participants