ruff/crates/red_knot_python_semantic/resources/mdtest/annotations/starred.md
Carl Meyer 3017b3b687
[red-knot] function parameter types (#14802)
## Summary

Inferred and declared types for function parameters, in the function
body scope.

Fixes #13693.

## Test Plan

Added mdtests.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-12-06 12:55:56 -08:00

453 B

Starred expression annotations

Type annotations for *args can be starred expressions themselves:

from typing_extensions import TypeVarTuple

Ts = TypeVarTuple("Ts")

def append_int(*args: *Ts) -> tuple[*Ts, int]:
    # TODO: tuple[*Ts]
    reveal_type(args)  # revealed: tuple

    return (*args, 1)

# TODO should be tuple[Literal[True], Literal["a"], int]
reveal_type(append_int(True, "a"))  # revealed: @Todo(full tuple[...] support)