Pyannotating
Structures your annotations and puts more information into them.
Installation
pip install pyannotating
Examples
Create annotation templates
from typing import Callable, Any, Optional, Iterable
from pyannotating import *
handler_of = AnnotationTemplate(Callable, [[input_annotation], Any])
handler_of[int | float]
Callable[[int | float], Any]
in a nested way
optional_reformer_of = AnnotationTemplate(
Callable,
[[input_annotation], AnnotationTemplate(Optional, [input_annotation])]
)
optional_reformer_of[int]
Callable[[int], Optional[int]]
with non-strict input annotation
summator_of = AnnotationTemplate(Callable, [[input_annotation | int, input_annotation], int])
summator_of[float]
Callable[[float | int, float], int]
Integrate comments into annotations
even = FormalAnnotation("Formal annotation of even numbers.")
number: even[int | float] = 42
or subgroups of existing types
natural_numbers = Subgroup(int, lambda number: number > 0)
isinstance(14, natural_numbers)
isinstance(-1.2, natural_numbers)
64 in natural_numbers
True
False
True
or downcasts
def transform(numbers: Special[range, Iterable[int]], additional: Special[None] = None) -> Any:
...
# Equals to
def transform(numbers: Iterable[int], additional: Any = None) -> Any:
...
or just some pre-made templates and annotations
many_or_one[int | float]
number
int | float | Iterable[int | float]
int | float | complex
Metadata
Release files for pyannotating 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyannotating-1.3.0.tar.gz | 16.6 kB | Without provenance | Details for pyannotating-1.3.0.tar.gz |
Release files / pyannotating-1.3.0.tar.gz
| Download URL | pyannotating-1.3.0.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5530a9d585367a2eea58048c90936e1a7aa8cf61f0e38cd8af0715656c54c2bf
|
|
BLAKE2b-256 checksum How to use checksums |
17971625d4b0e1a93d7242c0d386e41c9322b768254c8e2811bbcd7360b1dd5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|
Security for pyannotating 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.