Spec-classes

Latest version: v1.4.5

Safety actively analyzes 638418 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 4

1.1.0

This is a major release with several new features, and many bugfixes, largely motivated by the porting process of existing code from 0.3.4 core to 1.0.x.

**New features and enhancements:**
- Add top-level `.update()`, `.transform()` and `.reset()` mutation methods to spec-classes.
- Added `.update_<attr>` and `.update_<attr_singular>` methods for mutation of existing values (cf. overwriting them using `.with*()).
- `.transform*()` methods now work on attributes that have not been set (`MISSING` will be passed through instead to the transforms).
- `spec_property` gained an option `allow_attribute_error`, which can be set to `False` if you want to reduce the risk of errors being swallowed by `__getattr__` when something goes wrong (`AttributeError`s will then be recast into `NestedAttributeError`s).
- The `prepare` and `item_prepare` methods for attributes are now called *before* fallback construction (as in 0.3.x), allowing classes to do their own default imputation.
- Items in a `KeyedSet` container can now be looked up by instance/value (not just key). This brings it inline with `KeyedList`.
- If attribute namespaces clash (i.e. a collection's singular name collides with an existing attribute name), the singular name falls back to `<attr>_item`, and if that collides also a `RuntimeError` is raised rather than silently resulting in ambiguous behaviour.
- Removed the requirement that custom `__init__` methods *must* accept all attribute names as keyword arguments. This is still recommended.
- Documentation improvements and cleanups.

**Bugfixes and cleanups:**
- Improved the way in which the default constructor calls super-constructors (i.e. only once).
- During bootstrapping, the `__new__` fallback was incorrectly following subclass (rather than local) MROs.
- Fix regression in looking up attribute default overrides from downstream non-spec-class subclasses.
- Fix regression where invalidation maps were no longer generated for inherited unmanaged attributes/methods.
- `spec_property` now properly respects the updated `1.x` value preparation flow.
- Split up the unit tests into smaller chunks for increased maintainability.

1.0.1

This is a minor release that:

- fixes package metadata to reflect the new non-beta status.
- improves the performance of simple cases by a factor of ~2.
- removes a vestigial (undocumented) feature to set the attribute defaults using a class method.

1.0.0

First stable and documented release.

Page 4 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.