KEMBAR78
Error while multiplying a `SupportsInt` and an int · Issue #4758 · python/mypy · GitHub
Skip to content

Error while multiplying a SupportsInt and an int #4758

@akaptur

Description

@akaptur

I've got the following code:

from decimal import Decimal
d = Decimal('10')
x = max(d, 0) * 3

Mypy types max(d, 0) as a SupportsInt, which seems correct, but then complains:

test.py:3: error: Unsupported operand types for * ("SupportsInt" and "int")

I expect to be able to perform any operation between X and SupportsX if that operation is supported between X and another X.

This is mypy 0.570 and the underlying code is Python 3.6.1. I can reproduce this issue with no flags passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions