./devel/py-attrs, Attributes without boilerplate

[ CVSweb ] [ Homepage ] [ RSS ] [ Required by ] [ Add to tracker ]


Branch: CURRENT, Version: 18.2.0, Package name: py27-attrs-18.2.0, Maintainer: pkgsrc-users

attrs is an MIT-licensed Python package with class decorators that ease the
chores of implementing the most common attribute-related object protocols.

You just specify the attributes to work with and attrs gives you:

* a nice human-readable __repr__,
* a complete set of comparison methods,
* an initializer,
* and much more

without writing dull boilerplate code again and again.

This gives you the power to use actual classes with actual types in your code
instead of confusing tuples or confusingly behaving namedtuples.

So put down that type-less data structures and welcome some class into your
life!


Required to run:
[devel/py-setuptools] [lang/python27]

Required to build:
[pkgtools/cwrappers]

Master sites:

SHA1: 51a52e1afdd9e8c174ac0b65c2905a8360788dd2
RMD160: a1426eb3738d89a18d3180dcd8c5769acfa51efd
Filesize: 114.079 KB

Version history: (Expand)


CVS history: (Expand)


   2018-09-03 09:40:18 by Adam Ciarcinski | Files touched by this commit (3) | Package updated
Log message:
py-attrs: updated to 18.2.0

18.2.0:
Deprecations
Comparing subclasses using <, >, <=, and >= is now deprecated. The \ 
docs always claimed that instances are only compared if the types are identical, \ 
so this is a first step to conform to the docs.
Equality operators (== and !=) were always strict in this regard.

Changes
attrs now ships its own PEP 484 type hints. Together with mypy’s attrs plugin, \ 
you’ve got all you need for writing statically typed code in both Python 2 and \ 
3!
At that occasion, we’ve also added narrative docs about type annotations in attrs.
Added kw_only arguments to attr.ib and attr.s, and a corresponding kw_only \ 
attribute to attr.Attribute. This change makes it possible to have a generated \ 
__init__ with keyword-only arguments on Python 3, relaxing the required ordering \ 
of default and non-default valued attributes.
The test suite now runs with hypothesis.HealthCheck.too_slow disabled to prevent \ 
CI breakage on slower computers.
attr.validators.in_() now raises a ValueError with a useful message even if the \ 
options are a string and the value is not a string.
attr.asdict() now properly handles deeply nested lists and dictionaries.
Added attr.converters.default_if_none() that allows to replace None values in \ 
attributes. For example attr.ib(converter=default_if_none("")) \ 
replaces None by empty strings.
Fixed a reference leak where the original class would remain live after being \ 
replaced when slots=True is set.
Slotted classes can now be made weakly referenceable by passing \ 
@attr.s(weakref_slot=True).
Added cache_hash option to @attr.s which causes the hash code to be computed \ 
once and stored on the object.
Attributes can be named property and itemgetter now.
It is now possible to override a base class’ class variable using only class \ 
annotations.
   2018-05-10 10:24:40 by Adam Ciarcinski | Files touched by this commit (2) | Package updated
Log message:
py-attrs: updated to 18.1.0

18.1.0:
- x=X(); x.cycle = x; repr(x) will no longer raise a RecursionError, and will \ 
instead show as X(x=...).
- attr.ib(factory=f) is now syntactic sugar for the common case of \ 
attr.ib(default=attr.Factory(f)).
- Added attr.field_dict() to return an ordered dictionary of attrs attributes \ 
for a class, whose keys are the attribute names.
- The order of attributes that are passed into attr.make_class() or the these \ 
argument of @attr.s() is now retained if the dictionary is ordered (i.e. dict on \ 
Python 3.6 and later, collections.OrderedDict otherwise).
  Before, the order was always determined by the order in which the attributes \ 
have been defined which may not be desirable when creating classes \ 
programatically.
- In slotted classes, __getstate__ and __setstate__ now ignore the __weakref__ \ 
attribute.
- Setting the cell type is now completely best effort.
  This fixes attrs on Jython.
  We cannot make any guarantees regarding Jython though, because our test suite \ 
cannot run due to dependency incompatabilities.
- If attr.s is passed a *these* argument, it will not attempt to remove \ 
attributes with the same name from the class body anymore.
- The hash of attr.NOTHING is now vegan and faster on 32bit Python builds.
- The overhead of instantiating frozen dict classes is virtually eliminated.
- Generated __init__ methods now have an __annotations__ attribute derived from \ 
the types of the fields.
- We have restructured the documentation a bit to account for attrs' growth in scope.
   2018-01-01 22:08:46 by Adam Ciarcinski | Files touched by this commit (3) | Package updated
Log message:
py-attrs: updated to 17.4.0

17.4.0:

Backward-incompatible Changes
- The traversal of MROs when using multiple inheritance was backward:
  If you defined a class C that subclasses A and B like C(A, B), attrs would \ 
have collected the attributes from B *before* those of A.
  This is now fixed and means that in classes that employ multiple inheritance, \ 
the output of __repr__ and the order of positional arguments in __init__ \ 
changes.
  Due to the nature of this bug, a proper deprecation cycle was unfortunately \ 
impossible.
  Generally speaking, it's advisable to prefer kwargs-based initialization \ 
anyways – *especially* if you employ multiple inheritance and diamond-shaped \ 
hierarchies.
- The __repr__ set by attrs
  no longer produces an AttributeError
  when the instance is missing some of the specified attributes
  (either through deleting
  or after using init=False on some attributes).

  This can break code
  that relied on repr(attr_cls_instance) raising AttributeError
  to check if any attr-specified members were unset.

  If you were using this,
  you can implement a custom method for checking this::

      def has_unset_members(self):
          for field in attr.fields(type(self)):
              try:
                  getattr(self, field.name)
              except AttributeError:
                  return True
          return False

Deprecations
- The attr.ib(convert=callable) option is now deprecated in favor of \ 
attr.ib(converter=callable).
  This is done to achieve consistency with other noun-based arguments like \ 
*validator*.
  *convert* will keep working until at least January 2019 while raising a \ 
DeprecationWarning.

Changes
- Generated __hash__ methods now hash the class type along with the attribute values.
  Until now the hashes of two classes with the same values were identical which \ 
was a bug.
  The generated method is also *much* faster now.
- attr.ib\ ’s metadata argument now defaults to a unique empty dict instance \ 
instead of sharing a common empty dict for all.
  The singleton empty dict is still enforced.
- ctypes is optional now however if it's missing, a bare super() will not work \ 
in slots classes.
  This should only happen in special environments like Google App Engine.
- The attribute redefinition feature introduced in 17.3.0 now takes into account \ 
if an attribute is redefined via multiple inheritance.
  In that case, the definition that is closer to the base of the class hierarchy \ 
wins.
- Subclasses of auto_attribs=True can be empty now.
- Equality tests are *much* faster now.
- All generated methods now have correct __module__, __name__, and (on Python 3) \ 
__qualname__ attributes.
   2017-11-16 08:57:53 by Adam Ciarcinski | Files touched by this commit (2) | Package updated
Log message:
py-attrs: updated to 17.3.0

17.3.0:

Backward-incompatible Changes
- Attributes are not defined on the class body anymore.
  This means that if you define a class C with an attribute x, the class will \ 
*not* have an attribute x for introspe
ction anymore.
  Instead of C.x, use attr.fields(C).x or look at C.__attrs_attrs__.
  The old behavior has been deprecated since version 16.1.

Changes
- super() and __class__ now work on Python 3 when slots=True.
- Added type argument to attr.ib() and corresponding type attribute to \ 
attr.Attribute.

  This change paves the way for automatic type checking and serialization \ 
(though as of this release attrs does not make use of it).
  In Python 3.6 or higher, the value of attr.Attribute.type can alternately be \ 
set using variable type annotations
- The combination of str=True and slots=True now works on Python 2.
- attr.Factory is hashable again.
- Subclasses now can overwrite attribute definitions of their superclass.

  That means that you can -- for example -- change the default value for an \ 
attribute by redefining it.
- Added new option auto_attribs to @attr.s that allows to collect annotated \ 
fields without setting them to attr.ib().

  Setting a field to an attr.ib() is still possible to supply options like \ 
validators.
  Setting it to any other value is treated like it was passed as \ 
attr.ib(default=value) -- passing an instance of attr.Factory also works as \ 
expected.
   2017-10-05 08:49:16 by Adam Ciarcinski | Files touched by this commit (1)
Log message:
Disabled BUILD_DEPENDS: hypothesis now requires attrs
   2017-09-03 10:37:04 by Thomas Klausner | Files touched by this commit (182)
Log message:
Comment out dead MASTER_SITES/HOMEPAGEs.
   2017-05-24 21:41:34 by Adam Ciarcinski | Files touched by this commit (2)
Log message:
Changes 17.2.0:
Validators are hashable again. Note that validators may become frozen in the \ 
future, pending availability of no-overhead frozen classes.
   2017-05-20 08:01:46 by Adam Ciarcinski | Files touched by this commit (3)
Log message:
Changes 17.1.0:
Backward-incompatible changes:
* attrs will set the __hash__() method to None by default now. The way hashes \ 
were handled before was in conflict with Python’s specification. This may \ 
break some software although this breakage is most likely just surfacing of \ 
latent bugs. You can always make attrs create the __hash__() method using \ 
@attr.s(hash=True).
* Correspondingly, attr.ib‘s hash argument is None by default too and \ 
mirrors the cmp argument as it should.

Deprecations:
* attr.assoc() is now deprecated in favor of attr.evolve() and will stop working \ 
in 2018.

Changes:
Fix default hashing behavior. Now hash mirrors the value of cmp and classes are \ 
unhashable by default.
Added attr.evolve() that, given an instance of an attrs class and field changes \ 
as keyword arguments, will instantiate a copy of the given instance with the \ 
changes applied. evolve() replaces assoc(), which is now deprecated. evolve() is \ 
significantly faster than assoc(), and requires the class have an initializer \ 
that can take the field values as keyword arguments (like attrs itself can \ 
generate).
FrozenInstanceError is now raised when trying to delete an attribute from a \ 
frozen class.
Frozen-ness of classes is now inherited.
__attrs_post_init__() is now run if validation is disabled.
Added attr.validators.in_(options) that, given the allowed options, checks \ 
whether the attribute value is in it. This can be used to check constants, \ 
enums, mappings, etc.
Added attr.validators.and_() that composes multiple validators into one.
For convenience, the validator argument of @attr.s now can take a list of \ 
validators that are wrapped using and_().
Accordingly, attr.validators.optional() now can take a list of validators too.
Validators can now be defined conveniently inline by using the attribute as a \ 
decorator. Check out the examples to see it in action!
attr.Factory() now has a takes_self argument that makes the initializer to pass \ 
the partially initialized instance into the factory. In other words you can \ 
define attribute defaults based on other attributes.
Default factories can now also be defined inline using decorators. They are \ 
always passed the partially initialized instance.
Conversion can now be made optional using attr.converters.optional().
attr.make_class() now accepts the keyword argument bases which allows for \ 
subclassing.
Metaclasses are now preserved with slots=True.