./devel/py-attrs, Attributes without boilerplate

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

Branch: CURRENT, Version: 19.3.0, Package name: py37-attrs-19.3.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

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

Required to build:

Master sites:

SHA1: 5cad208b39fe854745c35b75f667eaf6400e2720
RMD160: 144b68d87435ed52ec06954aca2f8617ff0d84cf
Filesize: 129.372 KB

Version history: (Expand)

CVS history: (Expand)

   2020-05-16 11:03:23 by Adam Ciarcinski | Files touched by this commit (11)
Log message:
fix pytest versioned dep.
   2020-05-16 10:51:29 by Adam Ciarcinski | Files touched by this commit (1)
Log message:
py-attrs: pytest from versioned depends
   2019-10-15 09:53:35 by Adam Ciarcinski | Files touched by this commit (3) | Package updated
Log message:
py-attrs: updated to 19.3.0

- Fixed ``auto_attribs`` usage when default values cannot be compared directly \ 
with ``==``, such as ``numpy`` arrays.
   2019-10-07 22:25:01 by Adam Ciarcinski | Files touched by this commit (3) | Package updated
Log message:
py-attrs: updated to 19.2.0


Backward-incompatible Changes
- Removed deprecated ``Attribute`` attribute ``convert`` per scheduled removal \ 
on 2019/1.
- ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` do not consider subclasses \ 
comparable anymore.

  This has been deprecated since 18.2.0 and was raising a ``DeprecationWarning`` \ 
for over a year.

- The ``cmp`` argument to ``attr.s()`` and ``attr.ib()`` is now deprecated.

  Please use ``eq`` to add equality methods (``__eq__`` and ``__ne__``) and \ 
``order`` to add ordering methods (``__lt__``, ``__le__``, ``__gt__``, and \ 
``__ge__``) instead – just like with `dataclasses \ 

  Both are effectively ``True`` by default but it's enough to set ``eq=False`` \ 
to disable both at once.
  Passing ``eq=False, order=True`` explicitly will raise a ``ValueError`` though.

  Since this is arguably a deeper backward-compatibility break, it will have an \ 
extended deprecation period until 2021-06-01.
  After that day, the ``cmp`` argument will be removed.

  ``attr.Attribute`` also isn't orderable anymore.

- Updated ``attr.validators.__all__`` to include new validators.
- Slotted classes now use a pure Python mechanism to rewrite the ``__class__`` \ 
cell when rebuilding the class, so ``super()`` works even on environments where \ 
``ctypes`` is not installed.
- When collecting attributes using ``@attr.s(auto_attribs=True)``, attributes \ 
with a default of ``None`` are now deleted too.
- Fixed ``attr.validators.deep_iterable()`` and \ 
``attr.validators.deep_mapping()`` type stubs.
- ``attr.validators.is_callable()`` validator now raises an exception \ 
``attr.exceptions.NotCallableError``, a subclass of ``TypeError``, informing the \ 
received value.
- ``@attr.s(auto_exc=True)`` now generates classes that are hashable by ID, as \ 
the documentation always claimed it would.
- Added ``attr.validators.matches_re()`` that checks string attributes whether \ 
they match a regular expression.
- Keyword-only attributes (``kw_only=True``) and attributes that are excluded \ 
from the ``attrs``'s ``__init__`` (``init=False``) now can appear before \ 
mandatory attributes.
- The fake filename for generated methods is now more stable.
  It won't change when you restart the process.
- The value passed to ``@attr.ib(repr=…)`` can now be either a boolean (as \ 
before) or a callable.
  That callable must return a string and is then used for formatting the \ 
attribute by the generated ``__repr__()`` method.
- Added ``attr.__version_info__`` that can be used to reliably check the version \ 
of ``attrs`` and write forward- and backward-compatible code.
   2019-03-03 13:17:05 by Adam Ciarcinski | Files touched by this commit (2) | Package updated
Log message:
py-attrs: updated to 19.1.0

Backward-incompatible Changes
- Fixed a bug where deserialized objects with cache_hash=True could have \ 
incorrect hash code values.
  This change breaks classes with cache_hash=True when a custom __setstate__ is \ 
  An exception will be thrown when applying the attrs annotation to such a class.

- Add is_callable, deep_iterable, and deep_mapping validators.
  * is_callable: validates that a value is callable
  * deep_iterable: Allows recursion down into an iterable,
    applying another validator to every member in the iterable
    as well as applying an optional validator to the iterable itself.
  * deep_mapping: Allows recursion down into the items in a mapping object,
    applying a key validator and a value validator to the key and value in every \ 
    Also applies an optional validator to the mapping object itself.
  You can find them in the attr.validators package.
- Fixed stub files to prevent errors raised by mypy's disallow_any_generics = \ 
True option.
- Attributes with init=False now can follow after kw_only=True attributes.
- attrs now has first class support for defining exception classes.

  If you define a class using @attr.s(auto_exc=True) and subclass an exception, \ 
the class will behave like a well-behaved exception class including an \ 
appropriate __str__ method, and all attributes additionally available in an args \ 
- Clarified documentation for hashing to warn that hashable objects should be \ 
deeply immutable (in their usage, even if this is not enforced).
   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

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.

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 \ 
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 \ 
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 \ 
   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

- 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 \ 
- 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 \ 
- In slotted classes, __getstate__ and __setstate__ now ignore the __weakref__ \ 
- 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


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__ \ 
  Due to the nature of this bug, a proper deprecation cycle was unfortunately \ 
  Generally speaking, it's advisable to prefer kwargs-based initialization \ 
anyways – *especially* if you employ multiple inheritance and diamond-shaped \ 
- 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)):
                  getattr(self, field.name)
              except AttributeError:
                  return True
          return False

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

- 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 \ 
- 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.