You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
have a context manager class, whose enter returns another object rather than "self"
write with statement by that class's constructor
pylint will warns "no member" error due to it assume "target" is a context manager class
instance but in fact it was returned by context's enter method
sample code
class client_log(object):
def __init__(self, client):
self.client = client
def __enter__(self):
return self.client
def __exit__(self, exc_type, exc_value, traceback):
logger.info(self.client.get_log())
with client_log(client) as c:
return c.foo() **# pylint assume c is a client_log instance but c is a client instance**
pylint --version output
No config file found, using default configuration
pylint 1.9.4,
astroid 1.6.2
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered:
Steps to reproduce
instance but in fact it was returned by context's enter method
sample code
pylint --version output
No config file found, using default configuration
pylint 1.9.4,
astroid 1.6.2
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered: