py-undefined


Namepy-undefined JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://gitlab.com/mburkard/py-undefined
SummaryProvides an Undefined constant.
upload_time2024-01-04 01:23:19
maintainer
docs_urlNone
authorMatthew Burkard
requires_python>=3.9,<4.0
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Py-Undefined

![](https://img.shields.io/badge/License-ApacheV2-blue.svg)
![](https://img.shields.io/badge/code%20style-black-000000.svg)
![](https://img.shields.io/pypi/v/py-undefined.svg)

A light-weight dependency free library providing an `Undefined` type to Python.

## Install

Py-Undefined is on PyPI and can be installed with:

```shell
pip install py-undefined
```

Or with [Poetry](https://python-poetry.org/)

```shell
poetry add py-undefined
```

## Usage

The `Undefined` class from this module can be used as a variable type and a value.

```python
from py_undefined import Undefined

a: Undefined | int = Undefined

assert a is Undefined
```

## Why?

This is very useful to web frameworks that need to distinguish between receiving null
as a parameter value vs not receiving that parameter at all.

### Example

```python
# Framework that can now pass `Undefined` instead of `None` to method if param was absent from request.
@framework.method()
def update(a: int | Undefined, b: int | None | Undefined) -> None:
    if a is not Undefined:
        ...
    if b is not Undefined:
        ...
```

This allows for a client to use this method to update only what values are provided.

```python
my_client.update(b=1)  # Set b.
my_client.update(a=2)  # Set a without setting b to None.
my_client.update(b=None)  # b can be set to None explicitly.
```

## Support The Developer

<a href="https://www.buymeacoffee.com/mburkard" target="_blank">
  <img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png"
       width="217"
       height="60"
       alt="Buy Me A Coffee">
</a>

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/mburkard/py-undefined",
    "name": "py-undefined",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Matthew Burkard",
    "author_email": "matthew@gburkard.cloud",
    "download_url": "https://files.pythonhosted.org/packages/27/de/6eb784e4f834feb354f390f6799ebe688e3d22d8f2112da70bbd94a2c0ca/py-undefined-0.1.5.tar.gz",
    "platform": null,
    "description": "# Py-Undefined\n\n![](https://img.shields.io/badge/License-ApacheV2-blue.svg)\n![](https://img.shields.io/badge/code%20style-black-000000.svg)\n![](https://img.shields.io/pypi/v/py-undefined.svg)\n\nA light-weight dependency free library providing an `Undefined` type to Python.\n\n## Install\n\nPy-Undefined is on PyPI and can be installed with:\n\n```shell\npip install py-undefined\n```\n\nOr with [Poetry](https://python-poetry.org/)\n\n```shell\npoetry add py-undefined\n```\n\n## Usage\n\nThe `Undefined` class from this module can be used as a variable type and a value.\n\n```python\nfrom py_undefined import Undefined\n\na: Undefined | int = Undefined\n\nassert a is Undefined\n```\n\n## Why?\n\nThis is very useful to web frameworks that need to distinguish between receiving null\nas a parameter value vs not receiving that parameter at all.\n\n### Example\n\n```python\n# Framework that can now pass `Undefined` instead of `None` to method if param was absent from request.\n@framework.method()\ndef update(a: int | Undefined, b: int | None | Undefined) -> None:\n    if a is not Undefined:\n        ...\n    if b is not Undefined:\n        ...\n```\n\nThis allows for a client to use this method to update only what values are provided.\n\n```python\nmy_client.update(b=1)  # Set b.\nmy_client.update(a=2)  # Set a without setting b to None.\nmy_client.update(b=None)  # b can be set to None explicitly.\n```\n\n## Support The Developer\n\n<a href=\"https://www.buymeacoffee.com/mburkard\" target=\"_blank\">\n  <img src=\"https://cdn.buymeacoffee.com/buttons/v2/default-blue.png\"\n       width=\"217\"\n       height=\"60\"\n       alt=\"Buy Me A Coffee\">\n</a>\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Provides an Undefined constant.",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://gitlab.com/mburkard/py-undefined",
        "Repository": "https://gitlab.com/mburkard/py-undefined"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7033dd7c255a9f3a218f5f46577be232da5f13963189f9c58a599124b123c534",
                "md5": "9389059a88c25074eb33ff02562e1898",
                "sha256": "eac9ec57c3e3459924d39f07d41b65f8c160d8da3609dd4f6ac957720ef685e4"
            },
            "downloads": -1,
            "filename": "py_undefined-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9389059a88c25074eb33ff02562e1898",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 6712,
            "upload_time": "2024-01-04T01:23:21",
            "upload_time_iso_8601": "2024-01-04T01:23:21.697593Z",
            "url": "https://files.pythonhosted.org/packages/70/33/dd7c255a9f3a218f5f46577be232da5f13963189f9c58a599124b123c534/py_undefined-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27de6eb784e4f834feb354f390f6799ebe688e3d22d8f2112da70bbd94a2c0ca",
                "md5": "561de9b5f998f0ca160f9b381c0de1a5",
                "sha256": "2ad7df6347e4dc3373e4e8f0bd89c0788edcf34cd4a84ae92cac067d898d82e0"
            },
            "downloads": -1,
            "filename": "py-undefined-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "561de9b5f998f0ca160f9b381c0de1a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 6783,
            "upload_time": "2024-01-04T01:23:19",
            "upload_time_iso_8601": "2024-01-04T01:23:19.798071Z",
            "url": "https://files.pythonhosted.org/packages/27/de/6eb784e4f834feb354f390f6799ebe688e3d22d8f2112da70bbd94a2c0ca/py-undefined-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-04 01:23:19",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "mburkard",
    "gitlab_project": "py-undefined",
    "lcname": "py-undefined"
}
        
Elapsed time: 0.35567s