With the concatenate example from the typing doc, which works with mypy 0.950, if I split it to a file and a stub, stubtest starts to compain about Concatenate being used as a Callable argument:
totest.py:
fromthreadingimportLock# Use this lock to ensure that only one thread is executing a function# at any time.my_lock=Lock()
defwith_lock(f):
'''A decorator which provides a lock.'''definner(*args, **kwargs):
# Provide the lock as the first argument.returnf(my_lock, *args, **kwargs)
returninner@with_lockdefsum_threadsafe(lock, numbers):
'''Add a list of numbers together in a thread-safe manner.'''withlock:
returnsum(numbers)
# We don't need to pass in the lock ourselves thanks to the decorator.sum_threadsafe([1.1, 2.2, 3.3])
totest.pyi:
fromthreadingimportLockfromtypingimportConcatenate, ParamSpec, TypeVar, CallableP=ParamSpec('P')
R=TypeVar('R')
defwith_lock(f: Callable[Concatenate[Lock, P], R]) ->Callable[P, R]: ...stubtest run:
$ stubtest totest
error: not checking stubs due to mypy build errors:
totest.pyi:8: error: The first argument to Callable must be a list of types or "..."
With the concatenate example from the typing doc, which works with mypy 0.950, if I split it to a file and a stub, stubtest starts to compain about Concatenate being used as a Callable argument:
totest.py:totest.pyi:stubtest run:
$ stubtest totest error: not checking stubs due to mypy build errors: totest.pyi:8: error: The first argument to Callable must be a list of types or "..."