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

no-member when using a context manager #3157

Closed
HenkeA opened this issue Oct 3, 2019 · 3 comments
Closed

no-member when using a context manager #3157

HenkeA opened this issue Oct 3, 2019 · 3 comments

Comments

@HenkeA
Copy link

HenkeA commented Oct 3, 2019

I have the following code snippet:

class A:
    def __enter__(self):
        return self
    def __exit__(self, err_type, err, traceback):
        return
class B(A):
    def foo(self):
        pass
with B() as b:
    b.foo()

When running pylint on this, I get
no_member.py:10:4: E1101: Instance of '_Aa' has no 'b_method' member (no-member)

If I add a __enter__ and __exit__ to B, I get no error.
I only get this error depending on pylint version combined with astroid version
I have tried it with both Python 3.6 and 3.7
pylint 2.4.x - Always fails
pylint 2.3.x - Fails with newer astroid
pylint 2.3.x - Passes with astroid==2.2.5

I have seen some similar issues, but not found anyone really like this.

Steps to reproduce

  1. Use python 3.6 or 3.7
  2. Install latest pylint
  3. Run pylint on code above

Current behavior

no_member.py:10:4: E1101: Instance of '_Aa' has no 'b_method' member (no-member)

Expected behavior

Not that error

pylint --version output

pylint 2.4.2
astroid 2.3.1
Python 3.7.3 (default, Jun 19 2019, 21:29:22)

@sam-s
Copy link

sam-s commented Dec 31, 2019

I still observe this with

pylint 2.4.4
astroid 2.3.3
Python 3.7.6 (default, Dec 30 2019, 19:38:28) 
[Clang 11.0.0 (clang-1100.0.33.16)]

@sam-s
Copy link

sam-s commented Jan 2, 2020

should I create a new issue or will you reopen this one?

@PCManticore
Copy link
Contributor

@sam-s The fix has not been released yet, it will be part of 2.5 when we'll do the release.

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

No branches or pull requests

3 participants