erich


Nameerich JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryDecorators for better error handling
upload_time2023-04-11 19:02:25
maintainer
docs_urlNone
authorRobin Bergewski
requires_python>=3.7
licenseunlicense
keywords decorator decorators error errors
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Erich
enrich local errors without repeated try except using decorators

## Example

main.py
```py 
from typing import Callable

import erich

# Print a formatted message where format field names must 
# be present in the function signature.
@erich.fmt("Tried starting task {name} ({desc})")
def start_task(name: str, prio: int, fn: Callable, desc: str = None):
    schedule(prio, fn)

# Print that this function has been called but only include the prio
# in the output
@erich.signature("prio")
def schedule(prio: int, fn: Callable):
    can_schedule(prio)
    fn()

# add some nicer output to the final result
@erich.fmt("Cannot schedule task due to")
def can_schedule(prio: int):
    can_schedule_internal(prio)

# here the exception is actually raised with a limited
# amount of information which will be enriched by
# parent/calling functions.
def can_schedule_internal(prio: int):
    raise Exception(f"Cannot schedule something with prio {prio}. It's invalid")

start_task("test", -1, lambda: None, desc="very important")

```

```sh
> python main.py

..
stack trace
..

Tried starting task test (very important)
↳ during call of schedule(prio = -1)
 ↳ Cannot schedule task due to
  ↳ Cannot schedule something with prio -1. It's invalid
```


## Release
1. update version in setup.cfg, pyproject.toml and root \_\_init\_\_.py
2. build
```sh
python -m build
```
3. upload
```sh
python3 -m twine upload --repository pypi dist/*
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "erich",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "decorator,decorators,error,errors",
    "author": "Robin Bergewski",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/c2/d4/c160ddf93954fc3b927279b308ddb551210258e9bcc86eca367b42a4ae5d/erich-0.0.2.tar.gz",
    "platform": null,
    "description": "# Erich\nenrich local errors without repeated try except using decorators\n\n## Example\n\nmain.py\n```py \nfrom typing import Callable\n\nimport erich\n\n# Print a formatted message where format field names must \n# be present in the function signature.\n@erich.fmt(\"Tried starting task {name} ({desc})\")\ndef start_task(name: str, prio: int, fn: Callable, desc: str = None):\n    schedule(prio, fn)\n\n# Print that this function has been called but only include the prio\n# in the output\n@erich.signature(\"prio\")\ndef schedule(prio: int, fn: Callable):\n    can_schedule(prio)\n    fn()\n\n# add some nicer output to the final result\n@erich.fmt(\"Cannot schedule task due to\")\ndef can_schedule(prio: int):\n    can_schedule_internal(prio)\n\n# here the exception is actually raised with a limited\n# amount of information which will be enriched by\n# parent/calling functions.\ndef can_schedule_internal(prio: int):\n    raise Exception(f\"Cannot schedule something with prio {prio}. It's invalid\")\n\nstart_task(\"test\", -1, lambda: None, desc=\"very important\")\n\n```\n\n```sh\n> python main.py\n\n..\nstack trace\n..\n\nTried starting task test (very important)\n\u21b3 during call of schedule(prio = -1)\n \u21b3 Cannot schedule task due to\n  \u21b3 Cannot schedule something with prio -1. It's invalid\n```\n\n\n## Release\n1. update version in setup.cfg, pyproject.toml and root \\_\\_init\\_\\_.py\n2. build\n```sh\npython -m build\n```\n3. upload\n```sh\npython3 -m twine upload --repository pypi dist/*\n```\n",
    "bugtrack_url": null,
    "license": "unlicense",
    "summary": "Decorators for better error handling",
    "version": "0.0.2",
    "split_keywords": [
        "decorator",
        "decorators",
        "error",
        "errors"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c18e3db0b2ff5c54c7dce93c1c9b0210f20cab5e3b3b83e1038c91c5a82ba250",
                "md5": "c2c81c1688f3377fdfa83bd780b53931",
                "sha256": "3dc1e4828610db1ba5abef7660fa9c1403c215439524baa873834f954bd5063f"
            },
            "downloads": -1,
            "filename": "erich-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c2c81c1688f3377fdfa83bd780b53931",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4698,
            "upload_time": "2023-04-11T19:02:21",
            "upload_time_iso_8601": "2023-04-11T19:02:21.100106Z",
            "url": "https://files.pythonhosted.org/packages/c1/8e/3db0b2ff5c54c7dce93c1c9b0210f20cab5e3b3b83e1038c91c5a82ba250/erich-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c2d4c160ddf93954fc3b927279b308ddb551210258e9bcc86eca367b42a4ae5d",
                "md5": "de47a0b78aab895788483bb2ee7a7743",
                "sha256": "d29f0e098e55e7336a5a95688dc46cabcb297f9d2ef16f008af084294dfde8d3"
            },
            "downloads": -1,
            "filename": "erich-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "de47a0b78aab895788483bb2ee7a7743",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4322,
            "upload_time": "2023-04-11T19:02:25",
            "upload_time_iso_8601": "2023-04-11T19:02:25.912527Z",
            "url": "https://files.pythonhosted.org/packages/c2/d4/c160ddf93954fc3b927279b308ddb551210258e9bcc86eca367b42a4ae5d/erich-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-11 19:02:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "erich"
}
        
Elapsed time: 0.94162s