Skip to content

super() doesn't work in @contextlib.contextmanager #1484

@hotpxl

Description

@hotpxl

The following program

import contextlib

import attrs


@attrs.define
class D1:
    @contextlib.contextmanager
    def hello(self):
        yield None


@attrs.define
class D2(D1):
    @contextlib.contextmanager
    def hello(self):
        with super().hello():
            yield None

with D2().hello():
    pass

raises TypeError: super(type, obj): obj must be an instance or subtype of type

If I use super(D2, self) it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions