Skip to content

require-keyword-only-swap-prone-params

Risky-name positional parameters sharing a primitive annotation may be confused.

Why

A caller can exchange semantically distinct positional values without a type-checking failure.

Fix

If API, callback, and protocol compatibility permit, make the risky parameters keyword-only and update callers; otherwise retain the contract and suppress the warning locally.

Examples

Before — flagged Source and target IDs are positional
service.py
def move(source_id: str, target_id: str) -> None: ...
move("inbox", "archive")
After — preferred Source and target IDs are keyword-only
service.py
def move(*, source_id: str, target_id: str) -> None: ...
move(source_id="inbox", target_id="archive")

Formerly: kwonly-same-type-params