| 1 |
# Utility types for typeshed |
| 2 |
|
| 3 |
This package and its submodules contains various common types used by |
| 4 |
typeshed. It can also be used by packages outside typeshed, but beware |
| 5 |
the API stability guarantees below. |
| 6 |
|
| 7 |
## Usage |
| 8 |
|
| 9 |
The `_typeshed` package and its types do not exist at runtime, but can be |
| 10 |
used freely in stubs (`.pyi`) files. To import the types from this package in |
| 11 |
implementation (`.py`) files, use the following construct: |
| 12 |
|
| 13 |
```python |
| 14 |
from typing import TYPE_CHECKING |
| 15 |
|
| 16 |
if TYPE_CHECKING: |
| 17 |
from _typeshed import ... |
| 18 |
``` |
| 19 |
|
| 20 |
Types can then be used in annotations by either quoting them or |
| 21 |
using: |
| 22 |
|
| 23 |
```python |
| 24 |
from __future__ import annotations |
| 25 |
``` |
| 26 |
|
| 27 |
## API Stability |
| 28 |
|
| 29 |
You can use this package and its submodules outside of typeshed, but we |
| 30 |
guarantee only limited API stability. Items marked as "stable" will not be |
| 31 |
removed or changed in an incompatible way for at least one year. |
| 32 |
Before making such a change, the "stable" moniker will be removed |
| 33 |
and we will mark the type in question as deprecated. No guarantees |
| 34 |
are made about unmarked types. |