Releases: loyada/typedpy
minor improvement to protect developers
Performance improvement for trusted data
#240 Add a factory method(s) that assumes everything is valid and skips validation
#241 Add an option for deserialization from a "trusted source" for simple structures
Both of these improve performance by a factor of 10-25, depending on the Structure.
Examples from the tests:
Instantiation:
test_trusted_instantiation.py::test_trusted_instantiation_different_style
============================== 1 passed in 0.97s ===============================
Process finished with exit code 0
PASSED [100%]validated policies took: 0.8857707977294922
fast policies took: 0.03746604919433594
ratio: 23.641958967571146
Deserialization:
test_trusted_deserialization.py::test_trusted_deserialization_equivalent_to_regular
============================== 1 passed in 2.71s ===============================
Process finished with exit code 0
PASSED [100%]trusted serialization took: 0.10970401763916016
untrusted serialization took: 1.637939691543579
ratio: 14.930535150782818
Serialization optimization
Taking a performance test, that includes serializing deeply nested structures with lists, we have the following result:
Typedpy 2.19 serialization : 4.6 seconds
Typedpy 2.20 serialization: 3.1 seconds
Typedpy 2.20 "fast" serialization: 0.76 seconds
python stubs generation - static typing support in IDE
This is a major update.
it adds support for static typing, which was a major ommission in the typedpy set of features. This means that developers now get intellisense and type checking in Pycharm or VSC.
This is achieved by automatic generation of python stub files (*.pyi). See more detail in the docs.
Re-use improvements and defect fixes
Main improvements:
Significant improvements in Structure API
- re-use of classes - Extend, Partial, All FieldsRequired, Pick : https://typedpy.readthedocs.io/en/latest/structures.html#alternative-methods-for-structure-reuse
- Abstract Structures: https://typedpy.readthedocs.io/en/latest/structures.html#abstract-structure
- Ensuring the fields in a structure include all enum values: https://typedpy.readthedocs.io/en/latest/structures.html#ensuring-field-names-include-all-possible-enum-values
- PEP-604 style of fields https://typedpy.readthedocs.io/en/latest/structures.html#support-for-pep-604-style
- Throw exception if class definition is wrong. For example: if the default value is mutable.
Serialization
- Update code-Schema mapping to be up-to-date with recent features and serialization mappers
- Support for "Constant" in serialization mappers
- HasTypes mixin for a base class with multiple types
Other
Many defect fixes and small improvements to API's.
Better integration with Python (non-Typedpy) types
Major improvements:
issue #99 - better support for python field types. See [documentation] (https://typedpy.readthedocs.io/en/latest/fields.html#combining-python-and-typedpy-types-in-field-definition)
Minor improvements:
issue #93 - In a Versioned structure, assign version based on the number of mappers in _versions_mapper
Defects:
issue #95 - deserializer with camel_case_convert option requires _additionalProperties
Issue #96 - Serializing Optional SerializableField does not invoke serialize()
Issue #97 - Error deserializing versioned structures
Issue #98 - AnyOf[NoneField, SerializableField] does not serialize correctly
minor defects
Improvements to serialization/deserialization
#82 serialize field does not resolve field from a super class
#83 support deserializer by a discriminator field
#84 defaults should be assigned to the structure
#85 annotation form does not work with "from future import annotations"
#86 serialization mapper inheritance does not work correctly.
#88 support aggregation of multiple mappers in a single class
#89 Versions mapping
#90 Support deserialization of older versions to latest
grouping updates since 2.3
cleanup of code style issues.
Issue #69 allow bound method to be accepted as a value for field of type "Function"
Issue #70 allow to ignore assignment of None to a field. Useful when mapping from SQLAlchemy
Issue #71 Optional parameter to serializer/deserializer to convert between snake-case field names and camelCase. Useful when mapping between python names and names in Java/ Javascript, which use camelCase names
Issue #72 Fix a bug in Structure.fields_by_name() when using the syntax of field annotations.
Issue #73 clone a structure with overrides. Useful especially when you have an immutable structure, and you want to create another instance that is similar, but not identical.
Issue #74 expose mapping from exception String to a well formed structure for error info. Useful when the calling service/function needs a consistent way of handling errors
Issue #75 add option to output all errors when initializing, instead of failing on first error
Issue #76 fix error formating
issue #77 make decimal serializable
Issue #79 make repr behave like str
Issue #81 explicit cast