Skip to content

Ellipsis in Callable Type Annotations

Detects usage of ... (ellipsis) in the first argument of Callable type annotations, which bypasses parameter type checking.

Using Callable[..., ReturnType] indicates that the callable accepts any number of arguments of any type. The type checker cannot verify argument types or counts, which can lead to runtime errors.

What gets flagged

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from typing import Callable

def foo(callback: Callable[..., int]) -> int:
    return callback("wrong", "types")

def bar(x: int) -> int:
    return x

# This passes type checking but fails at runtime.
foo(bar)
Unsoundness Checker Output
Text Only
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
warning[callable-ellipsis-used]: Using `...` in `Callable` type annotations can lead to runtime type errors.
 --> main.py:3:19
  |
1 | from typing import Callable
2 |
3 | def foo(callback: Callable[..., int]) -> int:
  |                   ^^^^^^^^^^^^^^^^^^
4 |     return callback("wrong", "types")
  |
info: rule `callable-ellipsis-used` was selected in the configuration file

Mypy: No Diagnostic Emitted

Pyright: No Diagnostic Emitted

Ty: No Diagnostic Emitted