Changelog¶
Changelog¶
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Generally, more significant breaking changes will be put near the top of each category.
Documentation here: https://py-maybetype.readthedocs.io/en/latest/reference/
[0.12.0] - 2026-05-16¶
Added¶
Added
Warningcategories toerrors:MaybeInstanceWarning: Emitted when creating aMaybeobject directlyResultInstanceWarning: Emitted when creating aResultobject directlyNothingTypeInitWarning: Emitted when callingNothingType.__init__()for a second time instead of usingNothing
Changed¶
Resultis no longer hashable, but is still comparableInstead of comparing the hash of a tuple of the class and wrapped value,
Falseis 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 fromResult
[0.11.0] - 2026-04-06¶
Added¶
Added classes
Result,Ok, andErrto mimic the behavior of Rust’sResulttypeSee docs for all introduced methods: https://py-maybetype.readthedocs.io/en/latest/reference/index.html#maybetype.Result
Added the
errorsmoduleAdded exception
ResultUnwrapError
Added test module
test_result
Changed¶
Changed docstring of function
maybeto describe thepredicateparameter more succinctlyUpdated test
test_maybe.test_maybe_with_predicate_and_filterto ensuremaybe(val).filter(predicate)is equivalent tomaybe(val, predicate)Instancing
NothingTypemore than once now emits a warning suggesting the use of theNothingsingleton
[0.10.1] - 2026-03-22¶
Fixed¶
Fixed
.gitignorerule mistakenly excludingmaybetype/__init__.py, thus rendering the package effectively empty
[0.10.0] - 2026-03-21¶
Added¶
Added method
Maybe.castCasts the type of the wrapped value:
maybe(...).cast(int)→Maybe[int]
Added method
Maybe.flattenReplicates Rust’s
Option::flatten
Added method
Maybe.inspectReplicates Rust’s
Option::inspect
Added method
Maybe.reduceReplicates Rust’s
Option::reduce
Added method
Maybe.replaceReplicates Rust’s
Option::replace
Added method
Maybe.unwrap_or_elseReplicates Rust’s
Option::unwrap_or_else
Added method
Maybe.unzipReplicates Rust’s
Option::unzip
Added method
Maybe.xorReplicates Rust’s
Option::xor
Added method
Maybe.zipReplicates Rust’s
Option::zip
Added test
test_maybe.test_maybe_castAdded test
test_maybe.test_maybe_flattenAdded test
test_maybe.test_maybe_inspectAdded test
test_maybe.test_maybe_reduceAdded test
test_maybe.test_maybe_replaceAdded test
test_maybe.test_maybe_unwrap_or_elseAdded test
test_maybe.test_maybe_unzipAdded test
test_maybe.test_maybe_xorAdded test
test_maybe.test_maybe_zip
Changed¶
Renamed attribute
Maybe.valtoMaybe._val, should now be treated as a private attributeMethod
Maybe.and_thenparameterfuncnow must returnMaybe, making it more likeOption::and_thenMethod
Maybe.mapis no longer a static method and is now more in line withOption::mapin functionalityThe previous behavior of
Maybe.mapis largely unnecessary as it would produce the exact same result as callingMaybe.catwith a regularmap()object
Method
Maybe.attrnow optionally takes adefaultparameterMethod
Maybe.unwrapparameterexcnow defaults to a string instead ofNone, and no longer acceptsNoneRenamed class
_NothingtoNothingTypeThe class was marked as private to encourage use of the
Nothingsingleton instead, but since one could want to use the class for type annotations, and the singleton can’t be used for annotations, it was renamed to both make it no longer private and clarify that it is the type
Renamed method
Maybe.testtoMaybe.filterThe docstring for
Maybe.filterhas also been rewritten a bit to be more concise
A number of tests changed in
test_maybe:test_maybe_and_thenrewritten to test for its new functionalitytest_maybe_maprewritten to test for its new functionalitytest_maybe_thenrewritten to be less verboseRenamed
test_maybe_with_predicate_and_testtotest_maybe_with_predicate_and_filter
Removed¶
Removed method
Maybe.attr_orRemoved parameter
errfrom methodMaybe.attr
[0.9.0] - 2026-03-15¶
Added¶
Added method
Maybe.bindLargely the same as Haskell’s
>>=,x.bind(f)is essentially the same asx >>= f
Added test
test_maybe.test_bind
Changed¶
Added
from __future__ import annotationsimport tomaybetype/__init__.pyfor unquoted forward referencesAdded type annotation to
Maybe.valinMaybe.__init__to give more specificity fortyRemoved type variable from signature of
_Nothingclass as it’s never usedReplaced
# type: ignoredirective in testtest_maybe.test_nothing_instance_always_wraps_nonewith more specific# ty:ignore[invalid-argument-type]directiveExpanded test
test_maybe.test_equalityslightly
Fixed¶
Fixed incorrectly written test
test_maybe.test_maybe_or
[0.8.0] - 2026-02-16¶
Added¶
Added test
test_maybe.test_unwrap_nothing_callback
Changed¶
Updated a number of docstrings to fix errors or improve clarity
Changed
Maybe.unwrap()default error message to a more succinct “unwrapped Nothing”Method
Maybe.unwrap()argumentexccan now also be a string, in which caseValueErroris raised with that string as its sole argument if the instance wasNothingRenamed multiple tests in module
test_maybe:test_maybe_none_unwrap_error→test_unwrap_nothingtest_maybe_unwrap_or→test_unwrap_ortest_maybe_pattern_matching→test_pattern_matching
Renamed type variable
RtoUin signature ofMaybe.and_then()excargument of methodMaybe.unwrap()now expects a function that takes no arguments
[0.7.0] - 2026-02-05¶
Added¶
Added static method
Maybe.sequence()Added methods to
Maybe:and_then(): Similar toMaybe.then(), but returns aMaybeinstancetest(): ReturnsSomeif the instance isSomeand the test function returnsTruewhen called with the wrapped value, otherwise returnsNothing
Changed¶
Renamed static method
Maybe.int()toMaybe.try_int()Maybe.__hash__()now returnshash()called with the wrapped value instead of accessing its__hash__()methodMost type signatures now use the more standard type variable naming of
T,U,V…The only exception currently is the static method
Maybe.map(), which usesAandBsinceTalready belongs theMaybeclass’ scope and the method operates on unrelated types
Removed¶
Removed method
Maybe.this_or()Redundant,
maybe(x).this_or(y)is exactly the same asmaybe(x) or Some(y)
[0.6.0] - 2026-01-21¶
Changed¶
Project string has been changed from
"maybetype"to"py-maybetype"for getting metadata inconst
[0.5.0] - 2026-01-18¶
Added¶
Added
__match_args__attribute toMaybeto allow using its value inmatch/casepattern matchingAdded method
Maybe.unwrap_or()Added classes
Someand_Nothing_Nothingis intended to be used through theNothingsingleton instance, rather than constructing new instances of it, since effectively all_Nothinginstances should behave the sameInstances of
Someare always truthy, andNothingis always falsy
Added function
maybe()Returns either a
Someinstance or theNothingsingleton depending on the given value and predicate, similar to the previous functionality ofMaybe.__init__()Usage should now replace direct instancing of
Maybe
Changed¶
Maybe.__init__()body moved tomaybe()function, now simply assigns the passedvalto itsvalattributeA warning is now issued if
Maybe’s constructor is called directly
Replaced uses of
NoReturnwithNeverMaybe.get()now directly checks for the__getitem__method on the wrapped value instead of checkingSequence | MappingAnywhere
Maybe(None)would have been returned now returns theNothingsingleton
Fixed¶
Maybe.attr_or()no longer has a default argument ofNonefor itsdefaultparameter, as the docstring describes
[0.4.0] - 2026-01-02¶
Added¶
Added module
const
Changed¶
Updated all docstrings to use reStructuredText markup for Sphinx docs generation
Fixed¶
Fixed the example in
Maybe.cat’s docstring incorrectly attempting to use.cat()on the list ofMaybeobjects, now correctly shows usage ofMaybe.cat(vals)
[0.3.1] - 2025-12-31¶
Fixed¶
Corrected the docstring of
Maybe.__init__()’s description of thejust_conditionparameter, which incorrectly statedjust_conditionmust returnTruefor the constructor to returnMaybe(None)—the opposite is true,Maybe(None)is returned ifjust_conditionreturnsFalse
[0.3.0] - 2025-12-27¶
Added¶
Added the
just_conditionargument toMaybe’s constructor, a function that takes the to-be-wrapped value as an argument, which allows defining a custom condition in whichMaybe(None)will be returned if the function returnsFalsee.g.
Maybe(0) == Maybe(0), howeverMaybe(0, lambda x: x > 0) == Maybe(None)
[0.2.0] - 2025-12-08¶
Added¶
Added test module
tests/test_maybe.py