pytypes icon indicating copy to clipboard operation
pytypes copied to clipboard

Ellipsis not working in Callable annotation

Open jolaf opened this issue 5 years ago • 1 comments

The following code:

from typing import Callable

from pytypes import TypeChecker

def n() -> str:
    return "OK"

def f() -> Callable[..., str]:
    return n

with TypeChecker():
    print(f()())

fails as follows:

$ python3 Test.py
/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py:2534: UserWarning: the system profiling hook has changed unexpectedly
  warn('the system profiling hook has changed unexpectedly')
Traceback (most recent call last):
  File "Test.py", line 12, in <module>
    print(f()())
  File "Test.py", line 8, in f
    def f() -> Callable[..., str]:
TypeError: Callable[[arg, ...], result]: each arg must be a type. Got Ellipsis.

jolaf avatar Sep 05 '19 18:09 jolaf

Ellipsis is also not supported for tuples. E.g., Tuple[int, ...]. It would be very nice to get that supported!

r5r3 avatar Jan 09 '20 16:01 r5r3