Skip to main content

Py-Undefined

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

Install

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

pip install py-undefined

Or with Poetry

poetry add py-undefined

Usage

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

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

# 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.

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

Buy Me A Coffee

Metadata

Release files for py-undefined 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-undefined 0.1.7
File Size Uploaded
py-undefined-0.1.7.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-undefined 0.1.7
File Interpreter ABI Platform
py_undefined-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / py-undefined-0.1.7.tar.gz

Download URL py-undefined-0.1.7.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9fb4c64ea60ad71661db9567f3e3e2847fbb4e95cd02d3703418c0b3297f746a
BLAKE2b-256 checksum
How to use checksums
9ed8cc892022e629e1d8aff78627b095a81c780eb17740fadca00768c6768e67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.12 Linux/6.6.6-76060606-generic

Release files / py_undefined-0.1.7-py3-none-any.whl

Download URL py_undefined-0.1.7-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0f4c9b183ff6ab616b40748ab0edd80f46ff25b22b30433e3fed6a33971545a
BLAKE2b-256 checksum
How to use checksums
05dba8d4bc4c00ea8fbe483f5ef07ac394953779f24a13a8e14fadb3018cf633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.12 Linux/6.6.6-76060606-generic

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page