
Hi everyone, fresh for PyCon US 2017, the attrs team is relieved to present you the much-delayed attrs 17.1.0! Full changes: http://www.attrs.org/en/stable/changelog.html *** First the bad news: until 17.1.0, attrs’ logic regarding when to create a __hash__ method was in conflict with Python’s specification. If you use instances as dict keys or put them into sets, you have to either make them frozen explicitly by passing `frozen=True` or implicitly by pinky-swearing to not mutate them and force the creation of __hash__ using `hash=True`. *Please* double check before upgrading! We’re honestly sorry but didn’t see any better way to handle this. But mind you: hashing mutable objects is a bug so the breakage you’ll encounter may very well be the surfacing of latent, sneaky bugs. *** Now the good news! This release took very long (we promise improvement!) which led to the accumulation of a lot of great new features. A few highlights: # Decorators for validators
# Decorators for defaults & self in factories One of the most requested features: you can base the default of an attribute on a preceding attribute:
# New Validators: in_() & and_() in_() allows to check whether a value is part of an enum or any container:
and_() allows you to compose multiple validators to one. As syntactic sugar, you can also just pass a list to `validator=`. Therefore the following lines are equivalent: x = attr.ib(validator=attr.validators.and_(v1, v2, v3)) x = attr.ib(validator=[v1, v2, v3]) For the attrs team Hynek
participants (1)
-
Hynek Schlawack