Q:

What does typing.List<~T>[typing.Tuple[int]] mean in Python's typing lib?

While playing with Python's typing module I came across something curious:
>>> from typing import List, Tuple
>>> List[Tuple[int]]
typing.List<~T>[typing.Tuple[int]]

What's this Java-like syntax List<~T>? What does it mean?

A:

That's not actual Python syntax, so don't try to use it in a program. That said, this is how they chose to represent a generic type's type parameters. In a generic type's repr, the declared type parameters are listed in Java-like <> angle brackets, with a +, -, or ~ before each type parameter depending on whether that parameter is covariant, contravariant, or neither.
typing.List takes a single non-covariant, non-contravariant type parameter named T, so it gets a <~T> after the name.
You'll notice that typing.Tuple doesn't have any <> stuff after its name. Tuple is a weird special case, since it takes a variable number of type parameters.

A:

Let's see:
typing.List<~T>[typing.Tuple[int]]

typing.List means a type from the typing library, named List
<~T> means this type is generic, it's defined in terms of another type T
[typing.Tuple[int]] means type T is the type Tuple[int].

In natural language, you can read the definition like this:

typing.List<~T>[typing.Tuple[int]]: a standard List of one-int tuples

