Skip to content

False Positive E1129 (Not Context Manager) with class decorators #782

@nipunn1313

Description

@nipunn1313

Here is the code which hits false positive. Code runs fine, but hits pylint error for obj not being a contextmanager.

def contextmanagerdecorator(cls):
    class DecoClass(cls):
        def __enter__(self):
            pass
        def __exit__(self, *n, **kw):
            pass
    return DecoClass

@contextmanagerdecorator
class RegularClass(object):
    pass

obj = RegularClass()
with obj:
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueFriendly and approachable by new contributorsHelp wanted 🙏Outside help would be appreciated, good for new contributorsMinor 💅Polishing pylint is always nice

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions