https://github.com/alexmojaki/eval_type_backport
Like `typing._eval_type`, but lets older Python versions use newer typing features.
https://github.com/alexmojaki/eval_type_backport
Last synced: 3 months ago
JSON representation
Like `typing._eval_type`, but lets older Python versions use newer typing features.
- Host: GitHub
- URL: https://github.com/alexmojaki/eval_type_backport
- Owner: alexmojaki
- License: mit
- Created: 2023-11-10T14:35:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-21T20:09:39.000Z (7 months ago)
- Last Synced: 2025-03-31T18:21:58.160Z (3 months ago)
- Language: Python
- Size: 49.8 KB
- Stars: 13
- Watchers: 4
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# eval_type_backport
[](https://github.com/alexmojaki/eval_type_backport/actions) [](https://coveralls.io/github/alexmojaki/eval_type_backport) [](https://pypi.python.org/pypi/eval_type_backport) [](https://anaconda.org/conda-forge/eval-type-backport)
This is a tiny package providing a replacement for `typing._eval_type` to support newer typing features in older Python versions.
Yes, that's very specific, and yes, `typing._eval_type` is a protected function that you shouldn't normally be using. Really this package is specifically made for https://github.com/pydantic/pydantic/issues/7873.
Specifically, this transforms `X | Y` into `typing.Union[X, Y]`
and `list[X]` into `typing.List[X]` etc. (for all the types made generic in PEP 585)
if the original syntax is not supported in the current Python version.## Install
From PyPI:
```shell
pip install eval-type-backport
```or with Conda:
```shell
conda install -c conda-forge eval-type-backport
```