Код: Выделить всё
async def func1(
arg1: list[CustomType1 | CustomType2],
fn: Callable[..., Coroutine[Any, Any, CustomType3]],
**kwargs: str,
) -> list[CustomType3]:
return list(await asyncio.gather(*(fn(value, **kwargs) for value in arg1)))
Код: Выделить всё
async def fn1(
arg1: CustomType1,
arg2: str,
arg3: str
) -> CustomType3: ...
async def fn2(
arg1: CustomType2
) -> CustomType3: ...
Код: Выделить всё
fn: Callable[[CustomType1 | CustomType2, ...], Coroutine[Any, Any, CustomType3]]- : в строке ввода аргумента fn
Код: Выделить всё
Unexpected "..." - : в строке, куда возвращается func1
Код: Выделить всё
Too few arguments - : везде, где я вызываю fn1, и аналогичная ошибка при вызове fn2.
Код: Выделить всё
Argument 2 to "func1" has incompatible type "Callable[[CustomType1, str, str], Coroutine[Any, Any, CustomType3]]"; expected "Callable[[CustomType1 | CustomType2, Any], Coroutine[Any, Any, CustomType3]]"
(Я использую версию mypy 1.10.0, если это актуально)
Подробнее здесь: https://stackoverflow.com/questions/786 ... e-argument