Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

typing.List — legacy list type annotation

typing.List[T] describes a list of elements of type T. It remains available in Python 3.14, but new code should prefer list[T].

Version: Python 3.14; repository image, production runtime not attested

Syntax

from typing import List

values: List[int] = [1, 2, 3]
# Python 3.9+: values: list[int] = [1, 2, 3]

typing.List is a deprecated alias for list used in type annotations. After from typing import List, List[int] denotes a list of int elements.

Since Python 3.9, prefer list[int]: it needs no import. typing.List has been deprecated since that version, but remains available in Python 3.14 without an interpreter warning.

An annotation neither checks elements at runtime nor converts them; it supports static analysis. Create lists with [] or list(), not typing.List.

If an argument only needs iteration or sequence access, consider collections.abc.Iterable[T] or collections.abc.Sequence[T] instead of a concrete list.

Examples

from typing import List


def doubled(values: List[int]) -> list[int]:
    return [value * 2 for value in values]


numbers: List[int] = [1, 2, 3]
print(doubled(numbers))

Result

[2, 4, 6]

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources