Stewori / pytypes

Typing-toolbox for Python 3 _and_ 2.7 w.r.t. PEP 484.
Apache License 2.0
200 stars 20 forks source link

Ellipsis not working in Callable annotation #79

Open jolaf opened 5 years ago

jolaf commented 5 years ago

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.
r5r3 commented 4 years ago

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