admirabilis
admirabilis

Reputation: 2420

Union[Decimal, int] incompatible with Decimal?

Considering the following program:

from decimal import Decimal
from typing import Union

def foo(bar: Union[Decimal, int]):
    print(Decimal(1) + bar)
    print(bar + Decimal(1))

Why does mypy complain in the second print()?

$ mypy foo.py
foo.py: note: In function "foo":
foo.py:6: error: Unsupported operand types for + ("Union[Decimal, int]" and "Decimal")

I'm using mypy 0.3.1 on Python 3.5.1, Ubuntu 16.04.

EDIT: This seems to be a bug in mypy.

Upvotes: 2

Views: 842

Answers (1)

SukiCZ
SukiCZ

Reputation: 370

The bug was fixed in mypy version 0.630 with Pull Request #5545

Upvotes: 0

Related Questions