developing-tools


Namedeveloping-tools JSON
Version 2024.10.22 PyPI version JSON
download
home_pageNone
SummaryPackage designed to enhance the development process by providing a collection of tools/utilities
upload_time2024-10-22 13:56:31
maintainerNone
docs_urlNone
authorAdria Montoto
requires_python>=3.11
licenseNone
keywords decorator development python tools utilities
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <a name="readme-top"></a>

# 🐣💻 Developing Tools
<p align="center">
    <a href="https://github.com/adriamontoto/developing-tools/actions/workflows/test.yaml?event=push&branch=master" target="_blank">
        <img src="https://github.com/adriamontoto/developing-tools/actions/workflows/test.yaml/badge.svg?event=push&branch=master" alt="Test Pipeline">
    </a>
    <a href="https://github.com/adriamontoto/developing-tools/actions/workflows/lint.yaml?event=push&branch=master" target="_blank">
        <img src="https://github.com/adriamontoto/developing-tools/actions/workflows/lint.yaml/badge.svg?event=push&branch=master" alt="Lint Pipeline">
    </a>
        <a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/adriamontoto/developing-tools" target="_blank">
        <img src="https://coverage-badge.samuelcolvin.workers.dev/adriamontoto/developing-tools.svg" alt="Coverage Pipeline">
    </a>
    <a href="https://pypi.org/project/developing-tools" target="_blank">
        <img src="https://img.shields.io/pypi/v/developing-tools?color=%2334D058&label=pypi%20package" alt="Package Version">
    </a>
    <a href="https://pypi.org/project/developing-tools/" target="_blank">
        <img src="https://img.shields.io/pypi/pyversions/developing-tools.svg?color=%2334D058" alt="Supported Python Versions">
    </a>
</p>

The "Developing Tools" project is a Python 🐍 package designed to enhance the development process by providing a collection of tools/utilities aimed at improving debugging, performance measurement, error handling, ...

These tools ⚒️ are intended to assist developers in identifying performance bottlenecks, handling transient errors, and gaining insights into function behavior during runtime. The package is easy to install and use, making it a good addition to any Python developer's toolkit 🚀.
<br><br>


## Table of Contents
- [📥 Installation](#installation)
- [💻 Utilization](#utilization)
- [🔑 License](#license)
<br><br>

<p align="right">
    <a href="#readme-top">🔼 Back to top</a>
</p>



<a name="installation"></a>
## 📥 Installation
```bash
pip install developing-tools
```
<br><br>

<p align="right">
    <a href="#readme-top">🔼 Back to top</a>
</p>



<a name="utilization"></a>
## 💻 Utilization
### Execution Time
The `execution_time` decorator allows you to measure the execution time of a function. The decorator has one parameter:

- `output_decimals`: Number of decimal places to display in the output. Default is 10.

```python
from time import sleep
from developing_tools.functions import execution_time

@execution_time(output_decimals=2)
def too_slow_function() -> None:
    sleep(2)

too_slow_function()

# >>> Function "too_slow_function" took 2.00 seconds to execute.
```
<br>

<p align="right">
    <a href="#readme-top">🔼 Back to top</a>
</p>

### Retry It
The `retryit` decorator allows you to retry a function multiple times in case of failure. The decorator has two parameters:

- `attempts`: The number of attempts to execute the function, if _None_ the function will be executed indefinitely. Default is _None_.
- `delay`: The delay between attempts in seconds, if a tuple is provided the delay will be randomized between the two values. Default is 5 seconds.
- `raise_exception`: If _True_ the decorator will raise the last caught exception if the function fails all attempts. Default is _True_.
- `valid_exceptions`: A tuple of exceptions that the decorator should catch and retry the function, if _None_ the decorator will catch all exceptions. Default is _None_.

```python
from developing_tools.functions import retryit

@retryit(attempts=3, delay=0.5, raise_exception=True, valid_exceptions=(ValueError,))
def failing_function() -> None:
    raise ValueError('This function always fails!')

failing_function()

# >>> Function failed with error: "This function always fails!". Retrying in 0.50 seconds ...
# >>> Attempt [2/3] to execute function "failing_function".
# >>> Function failed with error: "This function always fails!". Retrying in 0.50 seconds ...
# >>> Attempt [3/3] to execute function "failing_function".
# >>> Function failed with error: "This function always fails!". No more attempts.
# Traceback (most recent call last):
#   File "<file_path>/main.py", line 7, in <module>
#     failing_function()
#   File "<file_path>/developing_tools/functions/retryit.py", line 132, in wrapper
#     raise exception
#   File "<file_path>/developing_tools/functions/retryit.py", line 124, in wrapper
#     return function(*args, **kwargs)
#            ^^^^^^^^^^^^^^^^^^^^^^^^^
#   File "<file_path>/main.py", line 5, in failing_function
#     raise ValueError('This function always fails!')
# ValueError: This function always fails!
```
<br>

<p align="right">
    <a href="#readme-top">🔼 Back to top</a>
</p>


### Print Parameters
The `print_parameters` decorator allows you to print the parameters of a function. The decorator has two parameters:

- `show_types`: If _True_ the decorator will print the types of the parameters. Default is _False_.
- `include_return`: If _True_ the decorator will print the return value of the function. Default is _True_.

```python
from developing_tools.functions import print_parameters

@print_parameters(show_types=True, include_return=True)
def normal_function(a: int, b: str, c: int, d) -> str:
    return a

normal_function(1, 'Hello', c=3, d=4)

# >>> Positional arguments:
# >>>         Argument 1: value "1", type int
# >>>         Argument 2: value "Hello", type str
# >>>
# >>> Keyword arguments:
# >>>         Argument c: value "3", supposed type int, real type int
# >>>         Argument d: value "4", supposed type Any, real type int
# >>>
# >>> Return value:
# >>>         "1", supposed type str, real type int
```
<br>

<p align="right">
    <a href="#readme-top">🔼 Back to top</a>
</p>

### Timeout
The `timeout` decorator allows you to set a maximum execution time for a function. The decorator has one parameter:

- `seconds`: The maximum number of seconds the function is allowed to execute before raising a _TimeoutError_. Default is 10 seconds.

```python
from time import sleep
from developing_tools.functions import timeout

@timeout(seconds=2)
def too_slow_function() -> None:
    sleep(5)

too_slow_function()

# >>> TimeoutError: Function too_slow_function exceeded the 2 seconds timeout.
```
<br><br>

<p align="right">
    <a href="#readme-top">🔼 Back to top</a>
</p>


<a name="license"></a>
## 🔑 License
This project is licensed under the terms of the [MIT license](https://choosealicense.com/licenses/mit/).
<br><br>

<p align="right">
    <a href="#readme-top">🔼 Back to top</a>
</p>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "developing-tools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "decorator, development, python, tools, utilities",
    "author": "Adria Montoto",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/76/57/88300b031be9471bdd7ed068be1af8d708f2a85fca6670556f5e4e3a6eb1/developing_tools-2024.10.22.tar.gz",
    "platform": null,
    "description": "<a name=\"readme-top\"></a>\n\n# \ud83d\udc23\ud83d\udcbb Developing Tools\n<p align=\"center\">\n    <a href=\"https://github.com/adriamontoto/developing-tools/actions/workflows/test.yaml?event=push&branch=master\" target=\"_blank\">\n        <img src=\"https://github.com/adriamontoto/developing-tools/actions/workflows/test.yaml/badge.svg?event=push&branch=master\" alt=\"Test Pipeline\">\n    </a>\n    <a href=\"https://github.com/adriamontoto/developing-tools/actions/workflows/lint.yaml?event=push&branch=master\" target=\"_blank\">\n        <img src=\"https://github.com/adriamontoto/developing-tools/actions/workflows/lint.yaml/badge.svg?event=push&branch=master\" alt=\"Lint Pipeline\">\n    </a>\n        <a href=\"https://coverage-badge.samuelcolvin.workers.dev/redirect/adriamontoto/developing-tools\" target=\"_blank\">\n        <img src=\"https://coverage-badge.samuelcolvin.workers.dev/adriamontoto/developing-tools.svg\" alt=\"Coverage Pipeline\">\n    </a>\n    <a href=\"https://pypi.org/project/developing-tools\" target=\"_blank\">\n        <img src=\"https://img.shields.io/pypi/v/developing-tools?color=%2334D058&label=pypi%20package\" alt=\"Package Version\">\n    </a>\n    <a href=\"https://pypi.org/project/developing-tools/\" target=\"_blank\">\n        <img src=\"https://img.shields.io/pypi/pyversions/developing-tools.svg?color=%2334D058\" alt=\"Supported Python Versions\">\n    </a>\n</p>\n\nThe \"Developing Tools\" project is a Python \ud83d\udc0d package designed to enhance the development process by providing a collection of tools/utilities aimed at improving debugging, performance measurement, error handling, ...\n\nThese tools \u2692\ufe0f are intended to assist developers in identifying performance bottlenecks, handling transient errors, and gaining insights into function behavior during runtime. The package is easy to install and use, making it a good addition to any Python developer's toolkit \ud83d\ude80.\n<br><br>\n\n\n## Table of Contents\n- [\ud83d\udce5 Installation](#installation)\n- [\ud83d\udcbb Utilization](#utilization)\n- [\ud83d\udd11 License](#license)\n<br><br>\n\n<p align=\"right\">\n    <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n\n\n<a name=\"installation\"></a>\n## \ud83d\udce5 Installation\n```bash\npip install developing-tools\n```\n<br><br>\n\n<p align=\"right\">\n    <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n\n\n<a name=\"utilization\"></a>\n## \ud83d\udcbb Utilization\n### Execution Time\nThe `execution_time` decorator allows you to measure the execution time of a function. The decorator has one parameter:\n\n- `output_decimals`: Number of decimal places to display in the output. Default is 10.\n\n```python\nfrom time import sleep\nfrom developing_tools.functions import execution_time\n\n@execution_time(output_decimals=2)\ndef too_slow_function() -> None:\n    sleep(2)\n\ntoo_slow_function()\n\n# >>> Function \"too_slow_function\" took 2.00 seconds to execute.\n```\n<br>\n\n<p align=\"right\">\n    <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n### Retry It\nThe `retryit` decorator allows you to retry a function multiple times in case of failure. The decorator has two parameters:\n\n- `attempts`: The number of attempts to execute the function, if _None_ the function will be executed indefinitely. Default is _None_.\n- `delay`: The delay between attempts in seconds, if a tuple is provided the delay will be randomized between the two values. Default is 5 seconds.\n- `raise_exception`: If _True_ the decorator will raise the last caught exception if the function fails all attempts. Default is _True_.\n- `valid_exceptions`: A tuple of exceptions that the decorator should catch and retry the function, if _None_ the decorator will catch all exceptions. Default is _None_.\n\n```python\nfrom developing_tools.functions import retryit\n\n@retryit(attempts=3, delay=0.5, raise_exception=True, valid_exceptions=(ValueError,))\ndef failing_function() -> None:\n    raise ValueError('This function always fails!')\n\nfailing_function()\n\n# >>> Function failed with error: \"This function always fails!\". Retrying in 0.50 seconds ...\n# >>> Attempt [2/3] to execute function \"failing_function\".\n# >>> Function failed with error: \"This function always fails!\". Retrying in 0.50 seconds ...\n# >>> Attempt [3/3] to execute function \"failing_function\".\n# >>> Function failed with error: \"This function always fails!\". No more attempts.\n# Traceback (most recent call last):\n#   File \"<file_path>/main.py\", line 7, in <module>\n#     failing_function()\n#   File \"<file_path>/developing_tools/functions/retryit.py\", line 132, in wrapper\n#     raise exception\n#   File \"<file_path>/developing_tools/functions/retryit.py\", line 124, in wrapper\n#     return function(*args, **kwargs)\n#            ^^^^^^^^^^^^^^^^^^^^^^^^^\n#   File \"<file_path>/main.py\", line 5, in failing_function\n#     raise ValueError('This function always fails!')\n# ValueError: This function always fails!\n```\n<br>\n\n<p align=\"right\">\n    <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n\n### Print Parameters\nThe `print_parameters` decorator allows you to print the parameters of a function. The decorator has two parameters:\n\n- `show_types`: If _True_ the decorator will print the types of the parameters. Default is _False_.\n- `include_return`: If _True_ the decorator will print the return value of the function. Default is _True_.\n\n```python\nfrom developing_tools.functions import print_parameters\n\n@print_parameters(show_types=True, include_return=True)\ndef normal_function(a: int, b: str, c: int, d) -> str:\n    return a\n\nnormal_function(1, 'Hello', c=3, d=4)\n\n# >>> Positional arguments:\n# >>>         Argument 1: value \"1\", type int\n# >>>         Argument 2: value \"Hello\", type str\n# >>>\n# >>> Keyword arguments:\n# >>>         Argument c: value \"3\", supposed type int, real type int\n# >>>         Argument d: value \"4\", supposed type Any, real type int\n# >>>\n# >>> Return value:\n# >>>         \"1\", supposed type str, real type int\n```\n<br>\n\n<p align=\"right\">\n    <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n### Timeout\nThe `timeout` decorator allows you to set a maximum execution time for a function. The decorator has one parameter:\n\n- `seconds`: The maximum number of seconds the function is allowed to execute before raising a _TimeoutError_. Default is 10 seconds.\n\n```python\nfrom time import sleep\nfrom developing_tools.functions import timeout\n\n@timeout(seconds=2)\ndef too_slow_function() -> None:\n    sleep(5)\n\ntoo_slow_function()\n\n# >>> TimeoutError: Function too_slow_function exceeded the 2 seconds timeout.\n```\n<br><br>\n\n<p align=\"right\">\n    <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n\n<a name=\"license\"></a>\n## \ud83d\udd11 License\nThis project is licensed under the terms of the [MIT license](https://choosealicense.com/licenses/mit/).\n<br><br>\n\n<p align=\"right\">\n    <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Package designed to enhance the development process by providing a collection of tools/utilities",
    "version": "2024.10.22",
    "project_urls": {
        "Homepage": "https://github.com/adriamontoto/developing-tools",
        "Issues": "https://github.com/adriamontoto/developing-tools/issues",
        "Repository": "https://github.com/adriamontoto/developing-tools"
    },
    "split_keywords": [
        "decorator",
        " development",
        " python",
        " tools",
        " utilities"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7d7db250943327397ace6e9a55686c9dce3e66b1964603a95aafdcfcc29425d",
                "md5": "02c6cac056a15510efb3d6fb37f48315",
                "sha256": "84510b1fa89e733b6442c49ef4f415a56f6b71fdc8ddc97abec7c2923044d0e1"
            },
            "downloads": -1,
            "filename": "developing_tools-2024.10.22-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "02c6cac056a15510efb3d6fb37f48315",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 14367,
            "upload_time": "2024-10-22T13:56:30",
            "upload_time_iso_8601": "2024-10-22T13:56:30.583619Z",
            "url": "https://files.pythonhosted.org/packages/f7/d7/db250943327397ace6e9a55686c9dce3e66b1964603a95aafdcfcc29425d/developing_tools-2024.10.22-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "765788300b031be9471bdd7ed068be1af8d708f2a85fca6670556f5e4e3a6eb1",
                "md5": "4188e6e24aee5392b22e44714cadcbcf",
                "sha256": "dd39613ade48358e2d11a4fd05c6bd3601bc3a7e357be7b502ee0da620826bce"
            },
            "downloads": -1,
            "filename": "developing_tools-2024.10.22.tar.gz",
            "has_sig": false,
            "md5_digest": "4188e6e24aee5392b22e44714cadcbcf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 12364,
            "upload_time": "2024-10-22T13:56:31",
            "upload_time_iso_8601": "2024-10-22T13:56:31.548527Z",
            "url": "https://files.pythonhosted.org/packages/76/57/88300b031be9471bdd7ed068be1af8d708f2a85fca6670556f5e4e3a6eb1/developing_tools-2024.10.22.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-22 13:56:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "adriamontoto",
    "github_project": "developing-tools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "developing-tools"
}
        
Elapsed time: 0.31915s