pyannotating


Namepyannotating JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://github.com/TheArtur128/Pyannotating
SummaryLibrary to structure annotations in your code
upload_time2023-01-21 17:09:24
maintainer
docs_urlNone
authorArthur
requires_python>=3.11
licenseGNU General Public License v3.0
keywords library annotations generation templating annotations informing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Pyannotating
Allows you to structure your annotations and put more information into them.<br>
Templates created with this library should preferably be placed in the annotations.py file.

### Installation
`pip install pyannotating`

### Features
You can create a template of your annotations
```python
from pyannotating import *
from typing import Callable, Any, Optional, Iterable

handler_of = AnnotationTemplate(Callable, [[input_annotation], Any])
```
and then create an annotation by this template
```python
handler_of[int | float]
```

what is equivalent
```python
Callable[[int | float], Any]
```

Also you can nest templates inside each other
```python
optional_handler_of = AnnotationTemplate(
    Callable,
    [[input_annotation], AnnotationTemplate(Optional, [input_annotation])]
)

optional_handler_of[int]
```

what results in
```python
Callable[[int], Optional[int]]
```

and use input_annotation in conjunction with something else
```python
summator_of = AnnotationTemplate(Callable, [[input_annotation | int, input_annotation], int])
summator_of[float]
```

to get
```python
Callable[[float | int, float], int]
```

In addition, you can integrate comments with your annotations
```python
even = FormalAnnotation("Formal annotation of even numbers.")

number: even[int | float] = 42
```

or annotate downcasts
```python
def transform(collection: Special[range, Iterable]) -> Any:
    ...
```

or just use some pre-made templates
```python
many_or_one[Callable]
method_of[int]
```

for getting
```python
Callable | Iterable[Callable]
Callable[[int, ...], Any]
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TheArtur128/Pyannotating",
    "name": "pyannotating",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "library,annotations,generation,templating,annotations,informing",
    "author": "Arthur",
    "author_email": "s9339307190@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/75/fc/1c14107aefb3b76b0f0e53792c039f710cd6906863cf877142412a2be975/pyannotating-1.2.1.tar.gz",
    "platform": null,
    "description": "## Pyannotating\r\nAllows you to structure your annotations and put more information into them.<br>\r\nTemplates created with this library should preferably be placed in the annotations.py file.\r\n\r\n### Installation\r\n`pip install pyannotating`\r\n\r\n### Features\r\nYou can create a template of your annotations\r\n```python\r\nfrom pyannotating import *\r\nfrom typing import Callable, Any, Optional, Iterable\r\n\r\nhandler_of = AnnotationTemplate(Callable, [[input_annotation], Any])\r\n```\r\nand then create an annotation by this template\r\n```python\r\nhandler_of[int | float]\r\n```\r\n\r\nwhat is equivalent\r\n```python\r\nCallable[[int | float], Any]\r\n```\r\n\r\nAlso you can nest templates inside each other\r\n```python\r\noptional_handler_of = AnnotationTemplate(\r\n    Callable,\r\n    [[input_annotation], AnnotationTemplate(Optional, [input_annotation])]\r\n)\r\n\r\noptional_handler_of[int]\r\n```\r\n\r\nwhat results in\r\n```python\r\nCallable[[int], Optional[int]]\r\n```\r\n\r\nand use input_annotation in conjunction with something else\r\n```python\r\nsummator_of = AnnotationTemplate(Callable, [[input_annotation | int, input_annotation], int])\r\nsummator_of[float]\r\n```\r\n\r\nto get\r\n```python\r\nCallable[[float | int, float], int]\r\n```\r\n\r\nIn addition, you can integrate comments with your annotations\r\n```python\r\neven = FormalAnnotation(\"Formal annotation of even numbers.\")\r\n\r\nnumber: even[int | float] = 42\r\n```\r\n\r\nor annotate downcasts\r\n```python\r\ndef transform(collection: Special[range, Iterable]) -> Any:\r\n    ...\r\n```\r\n\r\nor just use some pre-made templates\r\n```python\r\nmany_or_one[Callable]\r\nmethod_of[int]\r\n```\r\n\r\nfor getting\r\n```python\r\nCallable | Iterable[Callable]\r\nCallable[[int, ...], Any]\r\n```\r\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3.0",
    "summary": "Library to structure annotations in your code",
    "version": "1.2.1",
    "split_keywords": [
        "library",
        "annotations",
        "generation",
        "templating",
        "annotations",
        "informing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75fc1c14107aefb3b76b0f0e53792c039f710cd6906863cf877142412a2be975",
                "md5": "83002e9eb79ff4b5488506008a029c39",
                "sha256": "a14bafe1332dac98a9d41df95b7a04f104c4d50b6921e22bf4870327ccae6b3a"
            },
            "downloads": -1,
            "filename": "pyannotating-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "83002e9eb79ff4b5488506008a029c39",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 16203,
            "upload_time": "2023-01-21T17:09:24",
            "upload_time_iso_8601": "2023-01-21T17:09:24.996722Z",
            "url": "https://files.pythonhosted.org/packages/75/fc/1c14107aefb3b76b0f0e53792c039f710cd6906863cf877142412a2be975/pyannotating-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-21 17:09:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "TheArtur128",
    "github_project": "Pyannotating",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyannotating"
}
        
Elapsed time: 0.03194s