Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 13 days 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 (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-30T09:48:36.000Z (about 1 month ago)
- Last Synced: 2024-10-17T15:35:01.590Z (26 days ago)
- Language: Python
- Size: 43.9 KB
- Stars: 10
- Watchers: 4
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# eval_type_backport
[![Build Status](https://github.com/alexmojaki/eval_type_backport/workflows/Tests/badge.svg)](https://github.com/alexmojaki/eval_type_backport/actions) [![Coverage Status](https://coveralls.io/repos/github/alexmojaki/eval_type_backport/badge.svg)](https://coveralls.io/github/alexmojaki/eval_type_backport) [![Supports Python versions 3.8+, including PyPy](https://img.shields.io/pypi/pyversions/eval_type_backport.svg)](https://pypi.python.org/pypi/eval_type_backport) [![Anaconda's conda-forge channel](https://anaconda.org/conda-forge/eval-type-backport/badges/version.svg)](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
```