dynamic-cast


Namedynamic-cast JSON
Version 0.1.2a2 PyPI version JSON
download
home_pageNone
SummaryA Python library for flexible type casting of function arguments and return values based on type annotations.
upload_time2024-09-10 21:26:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Cxx-mlr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords type-casting type-annotations dynamic-typing python-type-hints type-conversion function-arguments type-checking callable-type data-types type-safety python-decorators runtime-type-checking type-inference generic-types automatic-type-casting type-system
VCS
bugtrack_url
requirements packaging typing-extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ---

# Dynamic Casting Utility

## Introduction

This Python module provides a dynamic casting utility that enables flexible casting of function arguments and return values based on type annotations. The utility is particularly useful for handling complex type conversions and ensuring compatibility between different data types.

## Installation

To use this dynamic casting utility, you can include it in your project by importing the `dynamic_cast` function from the module.

```python
from dynamic_cast import dynamic_cast
```

## Usage

### Basic Usage

The `dynamic_cast` function can be applied to functions to dynamically cast their arguments and return values based on the provided type annotations. It supports various scenarios, including handling iterable types, callables, and more.

```python
@dynamic_cast
def example_function(arg1: int, arg2: str) -> float:
    # Function logic here.
    return result
```

### Advanced Usage

For more advanced scenarios, the utility provides additional functionality, such as handling generic types, callable types, and class instances.

```python
@dynamic_cast
def advanced_function(arg1: List[int], arg2: Dict[str, float]) -> Tuple[str, int]:
    # Advanced function logic here.
    return result_tuple
```

## Examples.

### Dynamic Casting of Arguments.

```python
@dynamic_cast
def example_function(arg1: Union[str, int], arg2: List[float]) -> Tuple[str, List[int]]:
    # Function logic here
    return result_tuple
```

### Dynamic Casting of Class Instances

```python
class ExampleClass:
    @dynamic_cast
    def __init__(self, arg1: int, arg2: str) -> None:
        # Class initialization logic here
```

## Contributing

Feel free to contribute to the development of this dynamic casting utility. If you encounter any issues or have suggestions for improvement, please create an issue or submit a pull request.

## License

This dynamic casting utility is distributed under the MIT License. See the [LICENSE](LICENSE) file for more information.

---

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dynamic-cast",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "type-casting, type-annotations, dynamic-typing, python-type-hints, type-conversion, function-arguments, type-checking, callable-type, data-types, type-safety, python-decorators, runtime-type-checking, type-inference, generic-types, automatic-type-casting, type-system",
    "author": null,
    "author_email": "Santiago Papiernik <spapiernik12@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/cb/8e/87430a0882e10c611b6d7f38b3821614f7e17440d14b7dca2a37677af189/dynamic_cast-0.1.2a2.tar.gz",
    "platform": null,
    "description": "---\n\n# Dynamic Casting Utility\n\n## Introduction\n\nThis Python module provides a dynamic casting utility that enables flexible casting of function arguments and return values based on type annotations. The utility is particularly useful for handling complex type conversions and ensuring compatibility between different data types.\n\n## Installation\n\nTo use this dynamic casting utility, you can include it in your project by importing the `dynamic_cast` function from the module.\n\n```python\nfrom dynamic_cast import dynamic_cast\n```\n\n## Usage\n\n### Basic Usage\n\nThe `dynamic_cast` function can be applied to functions to dynamically cast their arguments and return values based on the provided type annotations. It supports various scenarios, including handling iterable types, callables, and more.\n\n```python\n@dynamic_cast\ndef example_function(arg1: int, arg2: str) -> float:\n    # Function logic here.\n    return result\n```\n\n### Advanced Usage\n\nFor more advanced scenarios, the utility provides additional functionality, such as handling generic types, callable types, and class instances.\n\n```python\n@dynamic_cast\ndef advanced_function(arg1: List[int], arg2: Dict[str, float]) -> Tuple[str, int]:\n    # Advanced function logic here.\n    return result_tuple\n```\n\n## Examples.\n\n### Dynamic Casting of Arguments.\n\n```python\n@dynamic_cast\ndef example_function(arg1: Union[str, int], arg2: List[float]) -> Tuple[str, List[int]]:\n    # Function logic here\n    return result_tuple\n```\n\n### Dynamic Casting of Class Instances\n\n```python\nclass ExampleClass:\n    @dynamic_cast\n    def __init__(self, arg1: int, arg2: str) -> None:\n        # Class initialization logic here\n```\n\n## Contributing\n\nFeel free to contribute to the development of this dynamic casting utility. If you encounter any issues or have suggestions for improvement, please create an issue or submit a pull request.\n\n## License\n\nThis dynamic casting utility is distributed under the MIT License. See the [LICENSE](LICENSE) file for more information.\n\n---\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2024 Cxx-mlr\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "A Python library for flexible type casting of function arguments and return values based on type annotations.",
    "version": "0.1.2a2",
    "project_urls": {
        "Repository": "https://github.com/Cxx-mlr/dynamic-cast"
    },
    "split_keywords": [
        "type-casting",
        " type-annotations",
        " dynamic-typing",
        " python-type-hints",
        " type-conversion",
        " function-arguments",
        " type-checking",
        " callable-type",
        " data-types",
        " type-safety",
        " python-decorators",
        " runtime-type-checking",
        " type-inference",
        " generic-types",
        " automatic-type-casting",
        " type-system"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e41673fa827bfc365a0d3b55707d0df5e7a2eecedd6aac9d79066ae4f2af6b6",
                "md5": "08d94565aa6b2f7c2722a2e71447125d",
                "sha256": "18d2a1a61b9cdb3f6c9e283fc1e96312d3a39fc450ab5923c59c3e08e1dc326a"
            },
            "downloads": -1,
            "filename": "dynamic_cast-0.1.2a2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "08d94565aa6b2f7c2722a2e71447125d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8319,
            "upload_time": "2024-09-10T21:26:49",
            "upload_time_iso_8601": "2024-09-10T21:26:49.705377Z",
            "url": "https://files.pythonhosted.org/packages/5e/41/673fa827bfc365a0d3b55707d0df5e7a2eecedd6aac9d79066ae4f2af6b6/dynamic_cast-0.1.2a2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb8e87430a0882e10c611b6d7f38b3821614f7e17440d14b7dca2a37677af189",
                "md5": "94bc5d4b35d0704661715cfae25d9e08",
                "sha256": "80962cd3a9ba2f6310ed5c4fe6a27df9e1d4baf773fb2e604b15afb14a668b72"
            },
            "downloads": -1,
            "filename": "dynamic_cast-0.1.2a2.tar.gz",
            "has_sig": false,
            "md5_digest": "94bc5d4b35d0704661715cfae25d9e08",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6649,
            "upload_time": "2024-09-10T21:26:50",
            "upload_time_iso_8601": "2024-09-10T21:26:50.643000Z",
            "url": "https://files.pythonhosted.org/packages/cb/8e/87430a0882e10c611b6d7f38b3821614f7e17440d14b7dca2a37677af189/dynamic_cast-0.1.2a2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-10 21:26:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Cxx-mlr",
    "github_project": "dynamic-cast",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "24.1"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.12.2"
                ]
            ]
        }
    ],
    "lcname": "dynamic-cast"
}
        
Elapsed time: 0.67259s