--- id: eval-type-backport version: "0.4.0" license: MIT license_treatment: permissive maintenance: active --- # eval-type-backport — Like `typing._eval_type`, but lets older Python versions use newer typing features. License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install eval-type-backport uv add eval-type-backport poetry add eval-type-backport ## Description # 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.7+, 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 package makes runtime typing inspection with the `typing` module possible with newer syntax in older Python versions. 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. For users of Pydantic, merely having this package installed should make Pydantic models with newer syntax work in older Python versions. Here's an example of how to use it... ## AI interpretation — verify before relying eval_type_backport enables runtime type inspection with modern Python typing syntax (like `X | Y` and `list[X]`) on older Python versions by transforming them into their `typing` module equivalents. It works transparently with Pydantic and other libraries that rely on `typing._eval_type`. Verdict: eval_type_backport is a lightweight, actively maintained utility that solves a real compatibility problem for projects using modern typing syntax on older Python versions. With no dependencies, permissive licensing, and clean API design, it is a low-risk addition for anyone supporting Python 3.7–3.9 alongside newer versions. [View on SkillFed](https://skillfed.io/packages/eval-type-backport) · [View on PyPI](https://pypi.org/project/eval-type-backport/)