
Aug. 29, 2019
1:07 p.m.
On Thu, Aug 29, 2019 at 10:03 PM Philippe Prados <philippe.prados@gmail.com> wrote:
No, it's not possible, because
int | str Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for |: 'type' and 'type'
Regards
It is possible because: Python 3.7.4 (default, Jul 9 2019, 18:13:23) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyright", "credits" or "license" for more information.
from __future__ import annotations def foo() -> int | str: ... pass ... foo.__annotations__ {'return': 'int | str'}
Please read PEP 563. Regards, -- Inada Naoki <songofacandy@gmail.com>