PY3.E1701

Not async context manager

Used when an async context manager is used with an object that does not implement the async context management protocol.

Noncompliant Code:

Copy
class ContextManager:
    def __enter__(self):
        pass

    def __exit__(self, *exc):
        pass
async def foo():
    async with ContextManager():
        pass

Compliant Code:

Copy
class AsyncContextManager:
    def __aenter__(self):
        pass

    def __aexit__(self, *exc):
        pass
async def foo():
    async with AsyncContextManager():
        pass

The content on this page is adapted from the Pylint User Guide, Copyright ©2003-2022, Logilab, PyCQA and contributors. All rights reserved. https://pylint.pycqa.org/en/latest/index.html#, and is used under the Python Software Foundation License Version 2. Examples, recipes, and other code in the Pylint documentation are additionally licensed under the Zero Clause BSD License.