Py-maybetype

Latest version: v0.14.0

Safety actively analyzes 971914 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

0.14.0

Added

- `Result` is now hashable
- Added `_val` type declaration in class body of `Ok` and `Err` as `T` and `E` respectively

Fixed

- `NothingType` now defines `__hash__()` so that `hash(Some(None))` does not equal `hash(Nothing)`

0.13.1

Fixed

- Fixed overload for `maybe()` incorrectly treating `maybe(T | None)` as resulting in
`Maybe[T | None]` when it should return `Maybe[T]`

0.13.0

Added

- Added method `Maybe.as_list()`
- Replicates Rust's [`Option::as_mut_slice`](https://doc.rust-lang.org/std/option/enum.Option.html#method.as_mut_slice)
- Added method `Maybe.as_tuple()`
- Replicates Rust's [`Option::as_slice`](https://doc.rust-lang.org/std/option/enum.Option.html#method.as_slice)
- Added classvar `NothingType._exists`
- Added function `maybe_exc()`
- Added overloads for `maybe()` to indicate that `maybe(None)` returns `NothingType`

Changed

- `Some` now supports wrapping `None`
- `Maybe.__bool__()` now checks whether itself `is Nothing` rather than checking the wrapped value
- All `self._val is not None` checks have been replaced with simply checking the truthiness of
`self`, making the statement that `Some` instances are all truthy and `Nothing` is falsy more
accurate
- `MaybeInstanceWarning` renamed to `MaybeInitError` and is now an exception
- Directly instancing `Maybe()` raises this error
- `NothingTypeInitWarning` renamed to `NothingTypeInitError` and is now an exception
- Directly instancing `NothingType()` after it has already been instanced raises this error
- `ResultInstanceWarning` renamed to `ResultInitError` and is now an exception
- Directly instancing `Result()` raises this error
- `Maybe` and `Result` methods no longer call `self.unwrap()`, instead accessing `self._val`
directly which is much faster, all usages of `self.unwrap()` had already checked for `Nothing`
- The existence of a `NothingType` instance is now checked in `NothingType.__new__()` instead of
`__init__()`, and a `bool` is used instead of an `int`
- Docstring for `Maybe.cast()` made more succinct
- Shortened description for parameter `err` in `Maybe.get()` docstring
- Parameter `accessor` of `Maybe.get()` is now typed as `object` instead of `Any`
- `Maybe.get()` no longer calls function `maybe()`, uses ternary to decide default return value
- Parameter `default` of `Maybe.get()` now defaults to `...` and takes a type `U | EllipsisType`
instead of `U | None` since `None` is now a supported `Some` value

Removed

- Removed module `const`
- Removed staticmethod `Maybe.try_int()`
- Removed classvar `NothingType._init_count`
- Removed method `Maybe.bind()`
- Equivalent to `Maybe.and_then()`

0.12.0

Added

- Added `Warning` categories to `errors`:
- `MaybeInstanceWarning`: Emitted when creating a `Maybe` object directly
- `ResultInstanceWarning`: Emitted when creating a `Result` object directly
- `NothingTypeInitWarning`: Emitted when calling `NothingType.__init__()` for a second time
instead of using `Nothing`

Changed

- `Result` is no longer hashable, but is still comparable
- Instead of comparing the hash of a tuple of the class and wrapped value, `False` is returned if
the compared objects are not of the same type, otherwise their wrapped values are compared
- Any warnings emitted now have a proper category assigned to them instead of only a message

Removed

- Removed `__hash__` method from `Result`

0.11.0

Added

- Added classes `Result`, `Ok`, and `Err` to mimic the behavior of Rust's `Result` type
- See docs for all introduced methods: <https://py-maybetype.readthedocs.io/en/latest/reference/index.html#maybetype.Result>
- Added the `errors` module
- Added exception `ResultUnwrapError`
- Added test module `test_result`

Changed

- Changed docstring of function `maybe` to describe the `predicate` parameter more succinctly
- Updated test `test_maybe.test_maybe_with_predicate_and_filter` to ensure
`maybe(val).filter(predicate)` is equivalent to `maybe(val, predicate)`
- Instancing `NothingType` more than once now emits a warning suggesting the use of the `Nothing`
singleton

0.10.1

Fixed

- Fixed `.gitignore` rule mistakenly excluding `maybetype/__init__.py`, thus rendering the package
effectively empty

Page 1 of 3

© 2026 Safety CLI Cybersecurity Inc. All Rights Reserved.