pytype icon indicating copy to clipboard operation
pytype copied to clipboard

`__future__.annotations` not triggering support for union-pipes (PEP 604)

Open markmcd opened this issue 2 years ago • 0 comments

This code runs in Py 3.8+:

from __future__ import annotations

def foo(opt: str | None): ...

But fails type-checking with pytype -V 3.8 (or 3.9), (No attribute '__or__' on 'str: Type[str]' or '__ror__' on 'None: None')

@Solumin pointed out:

PEP 604 (the | PEP) explicitly says PEP 563 (the __future__ annotations PEP) is sufficient for supporting PEP 604: https://peps.python.org/pep-0604/#change-only-pep-484-type-hints-to-accept-the-syntax-type1-type2

I think the decision was that "we probably should fix that", so here's a bug.

markmcd avatar Jun 02 '23 04:06 markmcd