Change History

2.10rc2

Changes

  • Remove simplejson as a fallback. Is no longer required with Python 3.8 plus and has worse performance that the builtin json module.

Bugfix

  • ResourceOptions.abstract flag was not being set for abstract AnnotatedResrouces.

2.10rc1

Changes

  • Simplify the internals of the Resource metaclass to make it easier to understand and maintain. Greater sharing of code between Resource and AnnotatedResource

    This change has not effect on the public API.

    Removes some compatibility code with versions prior to Python 3.8.

  • Support shadowing of fields on a resource. To enabled this feature set the allow_field_shadowing meta option to True. This allows for fields to be overridden on a resource.

    ResourceObjects now includes a shadow_fields listing all fields shadowed by this resource.

2.9

Changes

  • Add support for delayed resolution of types for composite fields. This allows for tree structures to be defined.

    Use DictAs.delayed(lambda: CurrentResource) to define a composite field that uses the current resource as the type for the dict.

2.8.1

Changes

  • Add beta contrib package for generating a JSON Schema from an Odin resource.

2.8

Changes

  • Change behaviour of create_resource_from_dict to not raise Validation errors from field.to_python when full_clean is False.

    Allows for invalid documents to still be loaded with invalid data to allow for correction of data and to prevent data loss.

  • Introduce Pre-commit, PyUpgrade, isort, ruff and black.

2.7

Bug fixes

  • TypedDictField now includes a prepare method to ensure types are cast correctly for serailisation.

2.6

  • Redesign of TraversalPath to make it more useful. Provides more information about the path to allow it to be used in more ways that just for fetching a value from a document.

2.5

  • Add ValidationErrorCollection helper for simplifying collection of errors in custom validation code.

  • Change behaviour of to_python method on a CompositeField to not do a full clean. This is not required as this should be completed during the validation stage. This prevents double validation and solves the issue of resources not being populated at all if any contained field contains an error.

2.4

  • Add contrib.rich to provide pre-built rich integration for rendering ValidationErrors as a tree

  • Improve ValidationError
    • Add for_field class method to simplify creating an exception related to a specific field.

    • Improve type annotations

  • Improve error handling of Validator rendering in sphinx contrib.

  • Improve description of validators for documentation.

  • Improve type annotations in validators.

  • Updates to documentation
    • Add decorators to docs

    • Additional docs for validators

    • Additional docs for Sphinx extension

2.3.1

Bug fix

  • ResourceOptions.composite_fields filtered composite field by Resource instead of ResourceBase.

2.3

  • Add meta option to specify how to format field names for serialisation. For example support being able to specify camelCase.

  • Updates to documentation - Add field_name_format meta option to docs - Document odin.utils

2.2

  • Fix a bug where annotated resource fields failed to get resolved.

  • Fix issues where functools.cached_property does not work on annotated resources as __set_name__ was not being called.

  • Updates to documentation - Introduce integration example for mapping Django models - Flesh out mapping documentation - Fix missing link to dict_codec reference.

2.1

Annotated Resources

  • Final fields are now mapped to ConstantField and require a default value.

  • Fix issue where the Toml codec did not recognise annotated resources in dump and dumps functions.

Breaking changes

  • Virtual fields ConstantField and CalculatedField now require keyword arguments for options.

2.0

  • Annotated Resources! - Use annotations to define your resources including Aliases for Email, URL’s and UUID’s

  • Drop support for Python <3.8, officially tested on Python 3.8+

  • Removed a number of dependencies that where only required for Python <3.8 eg (enum, six etc)

  • Removed deprecated features: - odin.csv_codec.ResourceReader - odin.serializers.DatetimeEcmaFormat

  • Improvements to typing and utilising of modern Python features

  • Fix bug in toml_codec that prevented the use of the include_type_field option.

  • Invalid choices now generate a ValueError exception

  • New fields for builtin Python types - odin.PathField - odin.RegexField

  • Use builtin datatime.timezone.utc instead of custom UTC instance

1.8.1

  • Change composite field to pass the resource the field is defined with rather than the name of the field, this allows namespace and typing to work correctly.

1.8.0

  • Allow types to be resolved by assuming a types names space (simplifies specification of types where the full name space can be assumed)

  • Inherit a custom type_field (this could cause unexpected side effects, although unlikely as this is a required change)

1.7.3

  • Fix bug where __classcell__ was not passed into super_new during metaclass construction. This causes a RuntimeError with Python 3.8+ if the metaclass is subclassed.

1.7.2

  • Fix an edge case bug where validators are not executed against empty list/dict fields.

  • Ensure that all validate and run_validators are executed on all entries in a typed list field

1.7.1

  • Tweak to generation of sphinx choices so TypedLists use choices from type.

  • Fix issue in Sphinx plugin where choices_doc_text was not used to format choice values.

  • Add TypedDictField to docs

1.7.0

  • Migrate from collections.Iterable to typing.Iterable to remove a warning

  • Add user defined metadata to Resource.Meta object

  • Add a reserved word guard, starting with fields (using fields causes clean_fields to go into a infinite recursion loop)

1.6.2

  • Migrate string formatting from % to “”.format

  • Apply black code style on all code

  • Improve some type hints

  • Add a Text block to XML Codec

1.6.1

  • Fix poetry config error that restricted Python versions > 3!

1.6.0

  • Remove encoding option for msgpack (this has been removed from msgpack itself)

  • Correct some typing inconsistencies (EnumField was the most obvious fix)

  • Package is now managed by poetry

  • Migrate to GitHub Actions

  • Static analysis and Coverage reporting now handled by SonarCloud.

  • Toml Codec

1.5.2

  • Relax overly tight dependency specification. Removed pyup.io it is not suitable for packages.

1.5

  • Improvements to sphinx autodoc generation

  • Improvements to enum support

1.0b2

  • Added a redesigned CSV codec Reader to address issues with handling row-by-row processing and handling of row-level errors.

  • Removed filter-query (moved to feature branch)

0.10b9

  • Added support for MultiPartField field type. A virtual field that allows for the easy generation of key values composed of several other fields.

  • Documentation updates and some initial type hints added (using :type… style)

  • Allow a virtual field to be identified as a key

  • Introduce a common base class for ALL field types, this allows them to be identified separately via hash (for sorting and keys)

  • Tweaked the new string.empty option so by default it behaves in the same way as it was previously defined (eg null assumes empty)

0.10b

  • Possible breaking change with date and time serializers, they no longer apply a timezone as this is expected to be managed by date and time fields.

  • Added getmeta tool for getting meta data.

  • Changes to Resource/Meta options to allow for them to be overridden.

  • Fixes regarding ResourceBase/Resource changes

0.9

  • Fixed bug preparing naive date and time values.

0.9a0

  • Support for multipart keys.

  • Support for naive dates and times.

  • Boolean fields now accept y/n as truthy

  • Change of Resource iterable base class

0.8.2

  • Migrated all tests to py.test

  • Support for Python 2.6 for _most_ features (some contrib features are not supported see docs for detail)

0.8.1

  • Bug fix for compatibility.deprecated decorator. Was breaking baldr when handling classes.

  • Some documentation fixes.

0.8

  • Added key_fields to resource meta options. This allows definition of which field(s) are used to uniquely identify the resource.

  • Added support to TraversalPath (and ResourceTraversalIterator) for using key_fields, both generating and traversing a Resource tree.

  • CodecDecodeError and CodecEncodeError now inherit off CodecError.

  • TraversalPath now raises multiple error types InvalidPathError, NoMatchError, and MultipleMatchesError

  • Some additional tweaks to inspect tool, as of now is still only available to Python 3.

  • Additional test cases.

0.7

  • Python 3.5 added for Travis CI test runner

  • Added empty flag to ListOf and DictOf files to validate if fields is allowed to be empty

  • Added key_choices to DictOf field to allow allow keys to be validated

  • Added TypedDictField this is a analog of the TypedListField but for dict objects

  • Project is now owned by the python-odin group

  • Initial work on combined string serialisation framework. This is to unify text serialisation support between the various codecs so additional serialises only need to be registered in a central location.

  • Added DictCodec, this is codec for converting between a dict structure and resource structure. As Resource.to_dict is explicitly designed to not act in a recursively this codec fills in a gap where a developer my require a nested dict to be generated.

  • Initial implementation of resource filtering. Filtering allows for a filter expression to be defined and used to filter a list of resources or ensure a particular resource matches the expression. Expressions are easy to define and read and allow for filtering against sub-resources etc.

  • Added caching to the results of mapping operations. Previously iterating through a mapping multiple times caused the mapping to be re-run. This has been made the default behaviour, if the previous behaviour is desired the MappingResult class can be provided to Mapping.apply instead of CachingMappingResult.

  • ResourceAdapter.apply_to now caches Meta object of matching resources types, previously a new meta object was created for each resource.

  • ResourceAdapterOptions.virtual_fields is now filtered using include/exclude options.

  • More tests, more docs

  • Various bug fixes.

0.6

Odin

  • Changed the generated type name for mapping factory to ensure a more unique name.

  • Pass through excluded_fields when generating types in mapping factory.

  • Added ignored fields parameter to be provided to Resource.convert_to method.

  • Added included fields parameter to the Mapping.update method

  • Updated the ResourceAdapter interface to match that of a normal Resource, can now be used in place of a Resource with any codec.

  • Added ResourceAdapter.apply_to method that simplifies applying a resource adapter to a list of Resources.

  • Updated create_resource_from_dict to accept a list and return a list of resources.

  • Fixed bug in auto-mapping generation of MapListOf fields to set the to_list flag correctly

  • Added forward_mapping_factory a shortcut version of mapping_factory when only a forward mapping is required.

  • Added the assign (similar to the define shortcut) shortcut for defining an assignment mapping

  • Fixed a bug where performing a full clean on a Resource that was created via a mapping would fail when a MappingResult object was encountered.

  • Added ResourceOptions.element_field_map for use in XML codecs

  • Added container flag and ResourceOptions.container_fields for XML style codecs

  • Large number of documentation updates

  • Fixed bug where Mapping.loop_idx was not being updated correctly, after 2 levels of nesting the wrong index was being updated.

Sphinx Integration

  • Add max length into resource documentation

  • Added description to validators that can be used in sphinx documentation