Add a `FlexibleAlias` to `mypy_extensions` (#5436)

Currently there is no way to define generic type aliases that do not
depend on their type arguments or that are just directly a type
variable.

`FlexibleAlias[T, typ]` creates a type that depends on `T` but that is
expanded to `typ` during type alias expansion.

One target use case for this is in creating conditionally defined type
aliases that depend on their argument under certain configurations but
not under others, for example:
```
if BOGUS:
    Bogus = FlexibleAlias[T, Any]
else:
    Bogus = FlexibleAlias[T, T]
```
1 file changed
tree: ec88b445dc83a34de492b34d47bae31fc1065dc5
  1. LICENSE
  2. MANIFEST.in
  3. mypy_extensions.py
  4. README.md
  5. setup.cfg
  6. setup.py
README.md

Mypy Extensions

The “mypy_extensions” module defines experimental extensions to the standard “typing” module that are supported by the mypy typechecker.