use-callable-ellipsis

Prefer Callable[…, T] for callable types with arbitrary parameters.

Valid examples

from typing import Callable
x: Callable[[int], int]
from typing import Callable
x: Callable[[int, int, ...], int]
from typing import Callable
x: Callable
Show more
from typing import Callable as C
x: C[..., int] = ...
from typing import Callable
def foo(bar: Optional[Callable[..., int]]) -> Callable[..., int]:
    ...
import typing as t
x: t.Callable[..., int] = ...
from typing import Callable
x: Callable[..., int] = ...

Invalid examples

from typing import Callable
x: Callable[[...], int] = ...

Suggested fix

from typing import Callable
x: Callable[..., int] = ...
Show more
import typing as t
x: t.Callable[[...], int] = ...

Suggested fix

import typing as t
x: t.Callable[..., int] = ...
from typing import Callable as C
x: C[[...], int] = ...

Suggested fix

from typing import Callable as C
x: C[..., int] = ...
from typing import Callable
def foo(bar: Optional[Callable[[...], int]]) -> Callable[[...], int]:
    ...

Suggested fix

from typing import Callable
def foo(bar: Optional[Callable[..., int]]) -> Callable[..., int]:
    ...