https://github.com/galacticdynamics/is_annotated
Check if a type hint is an `Annotated` type
https://github.com/galacticdynamics/is_annotated
python-typing
Last synced: 9 months ago
JSON representation
Check if a type hint is an `Annotated` type
- Host: GitHub
- URL: https://github.com/galacticdynamics/is_annotated
- Owner: GalacticDynamics
- License: mit
- Created: 2024-08-27T17:18:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-09T00:21:54.000Z (10 months ago)
- Last Synced: 2025-04-09T01:25:19.604Z (10 months ago)
- Topics: python-typing
- Language: Python
- Homepage: https://pypi.org/project/is-annotated
- Size: 42 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
is_annotated
Check if an object is an Annotated type.
This is a micro-package, containing the single function `isannotated` to check
if a type hint is an `Annotated` type. `Annotated` objects can't be checked by
normal `isinstance` checks.
## Installation
[![PyPI platforms][pypi-platforms]][pypi-link]
[![PyPI version][pypi-version]][pypi-link]
```bash
pip install is_annotated
```
## Documentation
[![Actions Status][actions-badge]][actions-link]
```python
from typing import Annotated
from is_annotated import isannotated
print(isannotated(1))
# False
print(isannotated(int))
# False
print(isannotated(Annotated[int, "1"]))
# True
```
[actions-badge]: https://github.com/GalacticDynamics/is_annotated/workflows/CI/badge.svg
[actions-link]: https://github.com/GalacticDynamics/is_annotated/actions
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/is_annotated
[conda-link]: https://github.com/conda-forge/is_annotated-feedstock
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
[github-discussions-link]: https://github.com/GalacticDynamics/is_annotated/discussions
[pypi-link]: https://pypi.org/project/is_annotated/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/is_annotated
[pypi-version]: https://img.shields.io/pypi/v/is_annotated