Skip to content

Mypy should look in metaclass for operations on class objects #2413

@sametmax

Description

@sametmax

Mypy complains about this line:

StringWrapper >> "foo"

With:

Unsupported left operand type for >> ("StringWrapper")

However, __rshift__ is defined on StringWrapper AND on StringWrapper's metaclass.

I understand the notation seems strange, calling shift on a class, but I'm making a library in which this API makes sense. The related code works, and applying >> does call __rshift__ on the metaclass. The only problem is mypy mentioning it. I can force ignore it, but I wish that dev using my lib won't have to do so.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions