Registry / serialization / pymaybe

pymaybe

JSON →
library0.1.6pypypi✓ verified 86d ago

pymaybe implements Haskell-style Maybe monad in Python, allowing safe chaining of operations on values that may be None. Version 0.1.6 is the latest; releases are infrequent and no breaking changes are documented. The library wraps values in a Maybe container and provides a .maybe attribute for safe access.

pip install pymaybe
INSTALL
IMPORT
SIG · PYMAYBE
P
pymaybe
serializationpythonv0.1.6
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

maybe
from pymaybe import maybe
import pymaybe
Direct import of the module does not expose the 'maybe' factory; must use from-import.

Wrap a dict in maybe() then chain .get() calls; each returns a Maybe object. Access the underlying value via .maybe.

from pymaybe import maybe # Wrap a potentially None value data = maybe({'name': 'Alice', 'job': None}) # Safe access using .maybe (returns maybe(None) if missing) job = data.get('job').maybe print(job) # None # Chaining: get nested key safely address = data.get('address').maybe.get('city').maybe print(address) # None
Debug
Known issues
gotchaAlways call .maybe at the end of a chain to unwrap the value; forgetting it returns a Maybe object, causing subtle bugs.
fix
Append .maybe to the final expression, e.g., result = maybe(x).get('key').maybe
affects: all
gotchaThe .maybe attribute on a Maybe(None) returns None, but the Maybe object itself is truthy. Use 'value.maybe is None' to check for absence.
fix
Use `if result.maybe is None:` instead of `if not result:`
affects: all
gotchaArithmetic and comparison operators on Maybe objects behave differently: maybe(5) + maybe(3) returns Maybe(8), but comparing with == checks the wrapped value, not identity.
fix
Be aware that operators work on the inner value. For identity checks, unwrap first.
affects: all
Errors
Common errors & fixes
AttributeError: module 'pymaybe' has no attribute 'Maybe'
Direct import of the module and attempting to use Maybe class directly.
fix
Use `from pymaybe import maybe` and then `maybe(value)`.
TypeError: 'Maybe' object is not subscriptable
Trying to use bracket indexing on a Maybe object, e.g., maybe_dict['key'].
fix
Use `.get('key')` method instead of bracket syntax.
Upgrade
Version history
0.1.6latest on PyPI · released Sep 28, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
pymaybe — pip install pymaybe · libregistry