| 1 |
# Typing Extensions |
| 2 |
|
| 3 |
[](https://gitter.im/python/typing) |
| 4 |
|
| 5 |
[Documentation](https://typing-extensions.readthedocs.io/en/latest/#) – |
| 6 |
[PyPI](https://pypi.org/project/typing-extensions/) |
| 7 |
|
| 8 |
## Overview |
| 9 |
|
| 10 |
The `typing_extensions` module serves two related purposes: |
| 11 |
|
| 12 |
- Enable use of new type system features on older Python versions. For example, |
| 13 |
`typing.TypeGuard` is new in Python 3.10, but `typing_extensions` allows |
| 14 |
users on previous Python versions to use it too. |
| 15 |
- Enable experimentation with new type system PEPs before they are accepted and |
| 16 |
added to the `typing` module. |
| 17 |
|
| 18 |
`typing_extensions` is treated specially by static type checkers such as |
| 19 |
mypy and pyright. Objects defined in `typing_extensions` are treated the same |
| 20 |
way as equivalent forms in `typing`. |
| 21 |
|
| 22 |
`typing_extensions` uses |
| 23 |
[Semantic Versioning](https://semver.org/). The |
| 24 |
major version will be incremented only for backwards-incompatible changes. |
| 25 |
Therefore, it's safe to depend |
| 26 |
on `typing_extensions` like this: `typing_extensions ~=x.y`, |
| 27 |
where `x.y` is the first version that includes all features you need. |
| 28 |
[This](https://packaging.python.org/en/latest/specifications/version-specifiers/#compatible-release) |
| 29 |
is equivalent to `typing_extensions >=x.y, <(x+1)`. Do not depend on `~= x.y.z` |
| 30 |
unless you really know what you're doing; that defeats the purpose of |
| 31 |
semantic versioning. |
| 32 |
|
| 33 |
## Included items |
| 34 |
|
| 35 |
See [the documentation](https://typing-extensions.readthedocs.io/en/latest/#) for a |
| 36 |
complete listing of module contents. |
| 37 |
|
| 38 |
## Contributing |
| 39 |
|
| 40 |
See [CONTRIBUTING.md](https://github.com/python/typing_extensions/blob/main/CONTRIBUTING.md) |
| 41 |
for how to contribute to `typing_extensions`. |