Skip to content

no-member when using a context manager #3157

@HenkeA

Description

@HenkeA

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions