attrs breaking changes
pypi114 curated breaking changes across major versions of attrs. Use this as a migration checklist before bumping dependencies.
- 21.2.0 \u2192 21.3.0behavior
When using `@define`, converters are now run by default when setting an attribute on an instance -- additionally to validators.
- 21.2.0 \u2192 21.3.0behavior
If the class-level *on_setattr* is set to `attrs.setters.validate` (default in `@define` and `@mutable`) but no field defines a validator, pretend that it's not set.
- 21.2.0 \u2192 21.3.0behavior
`attr.asdict(retain_collection_types=False)` (default) dumps collection-esque keys as tuples.
- 21.2.0 \u2192 21.3.0breaking
`attrs.resolve_types()` now resolves types of subclasses after the parents are resolved.
- 21.2.0 \u2192 21.3.0breaking
`__match_args__` are now generated to support Python 3.10's
- 21.2.0 \u2192 21.3.0breaking
The generated `__repr__` is significantly faster on Pythons with f-strings.
- 21.2.0 \u2192 21.3.0breaking
Attributes transformed via `field_transformer` are wrapped with `AttrsClass` again.
- 21.2.0 \u2192 21.3.0breaking
Generated source code is now cached more efficiently for identical classes.
- 21.2.0 \u2192 21.3.0breaking
Added `attrs.converters.to_bool()`.
- 21.2.0 \u2192 21.3.0breaking
Added new validators: `lt(val)` (\< val), `le(va)` (≤ val), `ge(val)` (≥ val), `gt(val)` (> val), and `maxlen(n)`.
- 21.2.0 \u2192 21.3.0breaking
`attrs` classes are now fully compatible with [cloudpickle](https://github.com/cloudpipe/cloudpickle) (no need to disable `repr` anymore).
- 21.2.0 \u2192 21.3.0breaking
Added new context manager `attrs.validators.disabled()` and functions `attrs.validators.(set|get)_disabled()`.
- 21.2.0 \u2192 21.3.0breaking
`attrs.validators.matches_re()` now accepts pre-compiled regular expressions in addition to pattern strings.
- 21.2.0 \u2192 21.3.0breaking
`import attrs` has finally landed!
- 21.1.0 \u2192 21.2.0breaking
Python 3.4 is now blocked using packaging metadata because `attrs` can't be imported on it anymore.
- 21.1.0 \u2192 21.2.0breaking
We had to revert the recursive feature for `attr.evolve()` because it broke some use-cases -- sorry!
- 20.2.0 \u2192 20.3.0api
The type stubs for `attr.s()` and `attr.make_class()` are not missing the *collect_by_mro* argument anymore.
- 20.2.0 \u2192 20.3.0api
`attr.asdict()` and `attr.astuple()` now treat `frozenset`s like `set`s with regards to the *retain_collection_types* argument.
- 20.2.0 \u2192 20.3.0breaking
`attr.s()` now has a *field_transformer* hook that is called for all `Attribute`s and returns a (modified or updated) list of `Attribute` instances.
- 20.2.0 \u2192 20.3.0breaking
`attr.define()`, `attr.frozen()`, `attr.mutable()`, and `attr.field()` remain **provisional**.
- 20.2.0 \u2192 20.3.0breaking
`kw_only=True` now works on Python 2.
- 20.2.0 \u2192 20.3.0breaking
`raise from` now works on frozen classes on PyPy.
- 20.1.0 \u2192 20.2.0api
`attr.define()` et al's hybrid behavior now also works correctly when arguments are passed.
- 20.1.0 \u2192 20.2.0breaking
The ergonomics of creating frozen classes using `@define(frozen=True)` and sub-classing frozen classes has been improved:
- 20.1.0 \u2192 20.2.0breaking
`attr.define()`, `attr.frozen()`, `attr.mutable()`, and `attr.field()` remain **provisional**.
- 20.1.0 \u2192 20.2.0breaking
`attr.define()` et al now correctly detect `__eq__` and `__ne__`.
- 20.1.0 \u2192 20.2.0breaking
It's possible to define custom `__setattr__` methods on slotted classes again.
- 20.1.0 \u2192 20.2.0breaking
In 20.1.0 we introduced the `inherited` attribute on the `attr.Attribute` class to differentiate attributes that have been inherited and those that have been defined directly on the class.
- 20.1.0 \u2192 20.2.0breaking
`zope.interface` is now a "soft dependency" when running the test suite; if `zope.interface` is not installed when running the test suite, the interface-related tests will be automatically skipped.
- 19.3.0 \u2192 20.1.0api
**Provisional** APIs called `attr.define()`, `attr.mutable()`, and `attr.frozen()` have been added.
- 19.3.0 \u2192 20.1.0api
Added `@attr.s(collect_by_mro=False)` argument that if set to `True` fixes the collection of attributes from base classes.
- 19.3.0 \u2192 20.1.0behavior
Fixed serialization behavior of non-slots classes with `cache_hash=True`.
- 19.3.0 \u2192 20.1.0breaking
It is now possible to prevent `attrs` from auto-generating the `__setstate__` and `__getstate__` methods that are required for pickling of slotted classes.
- 19.3.0 \u2192 20.1.0breaking
Fixed a `ValueError: Cell is empty` bug that could happen in some rare edge cases.
- 19.3.0 \u2192 20.1.0breaking
`attrs` can now automatically detect your own implementations and infer `init=False`, `repr=False`, `eq=False`, `order=False`, and `hash=False` if you set `@attr.s(auto_detect=True)`.
- 19.3.0 \u2192 20.1.0breaking
Added `attr.converters.pipe()`.
- 19.3.0 \u2192 20.1.0breaking
It is now possible to specify hooks that are called whenever an attribute is set **after** a class has been instantiated.
- 19.3.0 \u2192 20.1.0breaking
We have also provisionally added `attr.field()` that supplants `attr.ib()`.
- 19.3.0 \u2192 20.1.0breaking
Added `attr.resolve_types()`.
- 19.3.0 \u2192 20.1.0breaking
On Python 3, all generated methods now have a docstring explaining that they have been created by `attrs`.
- 19.3.0 \u2192 20.1.0breaking
Python 3.4 is not supported anymore.
- 19.3.0 \u2192 20.1.0deprecated
Less of a deprecation and more of a heads up: the next release of `attrs` will introduce an `attrs` namespace.
- 19.1.0 \u2192 19.2.0breaking
Added `attr.__version_info__` that can be used to reliably check the version of `attrs` and write forward- and backward-compatible code.
- 19.1.0 \u2192 19.2.0breaking
`__lt__`, `__le__`, `__gt__`, and `__ge__` do not consider subclasses comparable anymore.
- 19.1.0 \u2192 19.2.0breaking
Keyword-only attributes (`kw_only=True`) and attributes that are excluded from the `attrs`'s `__init__` (`init=False`) now can appear before mandatory attributes.
- 19.1.0 \u2192 19.2.0breaking
The fake filename for generated methods is now more stable.
- 19.1.0 \u2192 19.2.0breaking
The value passed to `@attr.ib(repr=…)` can now be either a boolean (as before) or a callable.
- 19.1.0 \u2192 19.2.0breaking
Updated `attr.validators.__all__` to include new validators added in [#425].
- 19.1.0 \u2192 19.2.0breaking
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.
- 19.1.0 \u2192 19.2.0breaking
Fixed `attr.validators.deep_iterable()` and `attr.validators.deep_mapping()` type stubs.
- 19.1.0 \u2192 19.2.0breaking
`attr.validators.is_callable()` validator now raises an exception `attr.exceptions.NotCallableError`, a subclass of `TypeError`, informing the received value.
- 19.1.0 \u2192 19.2.0breaking
`@attr.s(auto_exc=True)` now generates classes that are hashable by ID, as the documentation always claimed it would.
- 19.1.0 \u2192 19.2.0breaking
Added `attr.validators.matches_re()` that checks string attributes whether they match a regular expression.
- 19.1.0 \u2192 19.2.0deprecated
The `cmp` argument to `attr.s()` and `attr.ib()` is now deprecated.
- 19.1.0 \u2192 19.2.0removed
When collecting attributes using `@attr.s(auto_attribs=True)`, attributes with a default of `None` are now deleted too.
- 19.1.0 \u2192 19.2.0removed
Removed deprecated `Attribute` attribute `convert` per scheduled removal on 2019/1.
- 18.2.0 \u2192 19.1.0breaking
Add `is_callable`, `deep_iterable`, and `deep_mapping` validators.
- 18.2.0 \u2192 19.1.0breaking
Fixed a bug where deserialized objects with `cache_hash=True` could have incorrect hash code values.
- 18.2.0 \u2192 19.1.0breaking
`is_callable`: validates that a value is callable
- 18.2.0 \u2192 19.1.0breaking
`deep_iterable`: Allows recursion down into an iterable,
- 18.2.0 \u2192 19.1.0breaking
`deep_mapping`: Allows recursion down into the items in a mapping object,
- 18.2.0 \u2192 19.1.0breaking
Fixed stub files to prevent errors raised by mypy's `disallow_any_generics = True` option.
- 18.2.0 \u2192 19.1.0breaking
Attributes with `init=False` now can follow after `kw_only=True` attributes.
- 18.2.0 \u2192 19.1.0breaking
`attrs` now has first class support for defining exception classes.
- 18.2.0 \u2192 19.1.0breaking
Clarified documentation for hashing to warn that hashable objects should be deeply immutable (in their usage, even if this is not enforced).
- 17.3.0 \u2192 17.4.0api
`attr.ib`’s *metadata* argument now defaults to a unique empty `dict` instance instead of sharing a common empty `dict` for all.
- 17.3.0 \u2192 17.4.0breaking
Generated `__hash__` methods now hash the class type along with the attribute values.
- 17.3.0 \u2192 17.4.0breaking
`ctypes` is optional now however if it's missing, a bare `super()` will not work in slotted classes.
- 17.3.0 \u2192 17.4.0breaking
The traversal of MROs when using multiple inheritance was backward:
- 17.3.0 \u2192 17.4.0breaking
All generated methods now have correct `__module__`, `__name__`, and (on Python 3) `__qualname__` attributes.
- 17.3.0 \u2192 17.4.0breaking
The attribute redefinition feature introduced in 17.3.0 now takes into account if an attribute is redefined via multiple inheritance.
- 17.3.0 \u2192 17.4.0breaking
Equality tests are *much* faster now.
- 17.3.0 \u2192 17.4.0breaking
Subclasses of `auto_attribs=True` can be empty now.
- 17.3.0 \u2192 17.4.0deprecated
The `attr.ib(convert=callable)` option is now deprecated in favor of `attr.ib(converter=callable)`.
- 17.3.0 \u2192 17.4.0removed
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).
- 17.2.0 \u2192 17.3.0api
Added *type* argument to `attr.ib()` and corresponding `type` attribute to `attr.Attribute`.
- 17.2.0 \u2192 17.3.0breaking
`super()` and `__class__` now work with slotted classes on Python 3.
- 17.2.0 \u2192 17.3.0breaking
The combination of `str=True` and `slots=True` now works on Python 2.
- 17.2.0 \u2192 17.3.0breaking
`attr.Factory` is hashable again.
- 17.2.0 \u2192 17.3.0breaking
Subclasses now can overwrite attribute definitions of their base classes.
- 17.2.0 \u2192 17.3.0breaking
Added new option *auto_attribs* to `@attr.s` that allows to collect annotated fields without setting them to `attr.ib()`.
- 17.2.0 \u2192 17.3.0breaking
Instances of classes created using `attr.make_class()` can now be pickled.
- 17.2.0 \u2192 17.3.0breaking
Attributes are no longer defined on the class body.
- 16.3.0 \u2192 17.1.0api
For convenience, the *validator* argument of `@attr.s` now can take a list of validators that are wrapped using `and_()`.
- 16.3.0 \u2192 17.1.0api
Correspondingly, `attr.ib`'s *hash* argument is `None` by default too and mirrors the *cmp* argument as it should.
- 16.3.0 \u2192 17.1.0api
`attr.make_class()` now accepts the keyword argument `bases` which allows for subclassing.
- 16.3.0 \u2192 17.1.0api
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.
- 16.3.0 \u2192 17.1.0api
`attr.Factory()` now has a *takes_self* argument that makes the initializer to pass the partially initialized instance into the factory.
- 16.3.0 \u2192 17.1.0behavior
Default factories can now also be defined inline using decorators.
- 16.3.0 \u2192 17.1.0behavior
Fix default hashing behavior.
- 16.3.0 \u2192 17.1.0behavior
`attrs` will set the `__hash__()` method to `None` by default now.
- 16.3.0 \u2192 17.1.0breaking
Validators can now be defined conveniently inline by using the attribute as a decorator.
- 16.3.0 \u2192 17.1.0breaking
Frozen-ness of classes is now inherited.
- 16.3.0 \u2192 17.1.0breaking
`__attrs_post_init__()` is now run if validation is disabled.
- 16.3.0 \u2192 17.1.0breaking
Added `attr.validators.in_(options)` that, given the allowed `options`, checks whether the attribute value is in it.
- 16.3.0 \u2192 17.1.0breaking
Added `attr.validators.and_()` that composes multiple validators into one.
- 16.3.0 \u2192 17.1.0breaking
Accordingly, `attr.validators.optional()` now can take a list of validators too.
- 16.3.0 \u2192 17.1.0breaking
Conversion can now be made optional using `attr.converters.optional()`.
- 16.3.0 \u2192 17.1.0breaking
Metaclasses are now preserved with `slots=True`.
- 16.3.0 \u2192 17.1.0deprecated
`attr.assoc()` is now deprecated in favor of `attr.evolve()` and will stop working in 2018.
- 16.3.0 \u2192 17.1.0removed
`FrozenInstanceError` is now raised when trying to delete an attribute from a frozen class.
- 16.0.0 \u2192 16.1.0api
`attr.asdict()`'s `dict_factory` arguments is now propagated on recursion.
- 16.0.0 \u2192 16.1.0api
All instances where function arguments were called `cl` have been changed to the more Pythonic `cls`.
- 16.0.0 \u2192 16.1.0api
`attr.asdict()` now takes `retain_collection_types` as an argument.
- 16.0.0 \u2192 16.1.0breaking
Add `attr.attrs` and `attr.attrib` as a more consistent aliases for `attr.s` and `attr.ib`.
- 16.0.0 \u2192 16.1.0breaking
`attr.asdict()`, `attr.has()` and `attr.fields()` are significantly faster.
- 16.0.0 \u2192 16.1.0breaking
Add *frozen* option to `attr.s` that will make instances best-effort immutable.
- 16.0.0 \u2192 16.1.0deprecated
Accessing `Attribute` instances on class objects is now deprecated and will stop working in 2017.
- 16.0.0 \u2192 16.1.0deprecated
The serious-business aliases `attr.attributes` and `attr.attr` have been deprecated in favor of `attr.attrs` and `attr.attrib` which are much more consistent and frankly obvious in hindsight.
- 15.2.0 \u2192 16.0.0api
`attr.asdict()` can now produce arbitrary mappings instead of Python `dict`s when provided with a `dict_factory` argument.
- 15.2.0 \u2192 16.0.0breaking
Multiple performance improvements.
- 15.2.0 \u2192 16.0.0breaking
`__slots__` have arrived!
- 15.2.0 \u2192 16.0.0breaking
Python 3.3 and 2.6 are no longer supported.
- 15.2.0 \u2192 16.0.0breaking
Allow the case of initializing attributes that are set to `init=False`.
Get this data programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/breaking/pypi/attrs