4.0.0
⚠️ Breaking changes
ValueProviderand theULID.providerclass attribute have been removed. ULID generation is now handled by the newULIDGeneratortogether with pluggable monotonicity policies. Code that replacedULID.provideror subclassedValueProvidermust migrate to a customULIDGeneratorassigned toulid.default_generator.- The internal
validate_typedecorator was removed. TheULID.from_*constructors still raiseTypeErrorfor arguments of the wrong type, so runtime behaviour is unchanged.
Added
- A public
ULIDGeneratorclass that encapsulates ULID generation and can be configured with a custom clock, randomness source, and monotonicity policy. - Pluggable monotonicity policies —
StrictMonotonicPolicy(the default),LaxMonotonicPolicy, andPureRandomPolicy— together with theMonotonicityPolicyprotocol and theBaseMonotonicPolicybase class for implementing custom policies. - A module-level
ulid.default_generatorthat can be reassigned to routeULID()and theULID.from_*constructors through a customULIDGenerator.
Migration
import ulid
from ulid import ULIDGenerator, LaxMonotonicPolicy
# Before (removed):
# ULID.provider = MyValueProvider()
# After:
ulid.default_generator = ULIDGenerator(policy=LaxMonotonicPolicy())alternatively you can just create a generator object with the custom policy and create your ULID values with it
from ulid import ULIDGenerator, LaxMonotonicPolicy
generator = ULIDGenerator(policy=LaxMonotonicPolicy())
generator.generate()Full changelog: 3.2.1...4.0.0