KEMBAR78
A way to prevent MyPy from implictly checking the __r<magic method>__ · Issue #18945 · python/mypy · GitHub
Skip to content

A way to prevent MyPy from implictly checking the __r<magic method>__ #18945

@arnav-jain1

Description

@arnav-jain1

Feature

When type checking an overloaded magic method, mypy will implicitly reverse the operands and check it with the reversed operands. A flag to prevent this would be very helpful

Pitch

Some operations are not commutative and checking the reverse may end up with a different result causing confusion and errors. I am making a plugin and when checking a * b, whether or not it fails, it will also check b * a. This is incredibly annoying as if the former fails, it will check the latter. If the latter is successful, it will overwrite the failure. Being able to prevent this, either via a flag or some other way would be super nice, especially when writing plugins.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions