Skip to content

Commit 08bd63c

Browse files
committed
Library description
1 parent 809024a commit 08bd63c

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
1-
# Named-annotations
2-
Library for convenient generation of annotations for your code
1+
## Pyannotating
2+
Allows you to create similar annotations without copying them all the time.<br>
3+
It is advisable to place annotations created using this library in annotations.py file.
4+
5+
### Installation
6+
`pip install Pyannotating`
7+
8+
### Examples
9+
Creating a factory of your annotations
10+
```python
11+
from pyannotating import CustomAnnotationFactory, input_annotation
12+
from typing import Callable
13+
14+
handler_of = CustomAnnotationFactory(Callable, [[input_annotation], any])
15+
```
16+
Now you can create an annotation by this factory
17+
```python
18+
handler_of[int | float]
19+
```
20+
21+
What is equivalent
22+
```python
23+
Callable[[int | float], any]
24+
```
25+
26+
Also you can use Union with input_annotation
27+
```python
28+
summator_of = CustomAnnotationFactory(Callable, [[input_annotation | str, input_annotation | int], str | int])
29+
summator_of[SomeCustomNumber]
30+
```
31+
32+
What results in
33+
```python
34+
Callable[[SomeCustomNumber | str, SomeCustomNumber | int], str | int]
35+
```
36+
37+
Ultimately you can annotate by the resulting annotations
38+
```python
39+
def some_operation_by(main: handler_of[int | float], *middleware: summator_of[SomeCustomNumber]) -> handler_of[int | float]:
40+
...
41+
```

0 commit comments

Comments
 (0)