Skip to content

Releases: jetavator/wysdom

0.3.0-rc1

12 Mar 22:57
Compare
Choose a tag to compare
0.3.0-rc1 Pre-release
Pre-release

Enhancements

  • #64 - Allow property type in user property to be a python enum and translate it to a jsonschema enum

    Sometimes a property should have one of a set of strictly enumerated values.
    For this use case it is possible to use a Python Enum as the property type
    of a given wysdom.UserProperty:

    from enum import Enum
    
    
    class Color(Enum):
        PINK = "pink"
        ORANGE = "orange"
    
    
    class Vehicle(UserObject):
        color = UserProperty(Color)
    
    
    >>> my_vehicle = Vehicle({"color": "orange"})
    >>> my_vehicle.color
    
    <Color.ORANGE: 'orange'>
    
  • #65 - Regular expression support

    If you need to restrict the values that a UserProperty
    can take according to a regex pattern, you can specify this
    using the pattern parameter::

    class Vehicle(UserObject):
        rgb_hex_color = UserProperty(str, pattern=r"^[0-9a-f]{6}$")
    

    If your dictionary only has certain keys that are valid for your application
    according to a regex pattern, you can specify this with the parameter
    key_pattern:

    color_names = UserProperty(
        SchemaDict(ColorName),
        key_pattern=r"^[0-9a-f]{6}$"
    )
    
  • #66 - Convenience function: properties

    Introduces the convenience function wysdom.properties so that:

    for name, parameter in MyObject.__json_schema_properties__.properties.items():
    

    can be simplified to:

    for name, parameter in wysdom.properties(MyObject).items():
    
  • #67 - Convenience classes: ListProperty and DictProperty

    Introduces the convenience classes wysdom.ListProperty and wysdom.DictProperty so that:

    people_list = UserProperty(SchemaArray(Person))
    

    can be simplified to:

    people_list = ListProperty(Person)
    

    and

    people_dict = UserProperty(SchemaDict(Person))
    

    can be simplified to:

    people_dict = DictProperty(Person)
    

0.2.3

16 Jan 22:59
0a521c6
Compare
Choose a tag to compare

Bug fixes

  • #56 - New subclasses of a UserObject that implements the RegistersSubclasses mixin will now be valid input, even if no subclasses were originally defined when the UserObject was referenced.

0.2.2

14 Jan 21:31
4248f63
Compare
Choose a tag to compare

Bug fixes

  • #53 - New subclasses of a UserObject that implements the RegistersSubclasses mixin will now be valid input, even if those subclasses were defined after the object that references their superclass.

0.2.1

27 Dec 14:59
f39237e
Compare
Choose a tag to compare

Bug fixes

  • #49 - Removed an erroneous print statement that was causing verbose debug output

0.2.0

27 Dec 14:48
fcaddde
Compare
Choose a tag to compare

Enhancements

#47 - Allow multiple subclasses of RegistersSubclasses to have the same register_as value. Classes and instances returned by registered_subclass and registered_subclass_instance are now always strict subclasses of the class invoking the method, and will only throw a KeyError if there are multiple valid subclasses with the same key. See the docstring for RegisteredSubclasses.registered_subclass for more details.

Compatibility Changes

#47 - Please note that this update breaks backward compatibility on RegisteredSubclasses.registered_subclasses which now returns Dict[str, List[Type[RegistersSubclasses]]] instead of Dict[str, Type[RegistersSubclasses]]. If you have existing code that uses this method, please replace calls to RegisteredSubclasses.registered_subclasses() with RegisteredSubclasses.registered_subclasses()[0].

0.1.5

13 Jun 20:02
4e01aab
Compare
Choose a tag to compare

Enhancements

  • #45 - added parameter persist_defaults to UserProperty. If this parameter is set to True and a UserProperty also has either the default or default_function parameter , when the UserProperty returns a default value that value will also be explicitly stored in the underlying data object. This was the default behavior before 0.1.4. This is often desirable behavior if the UserProperty returns another object and your code expects it to return the same object instance each time it is accessed, and so is now provided as a configurable parameter.

Bug fixes

  • #42 - default values of a UserProperty will now be returned as the type declared in property_type, as before 0.1.4

0.1.4

12 Jun 21:09
66a9251
Compare
Choose a tag to compare

Bug Fixes:

  • #42 - accessing a UserProperty that has a default or default_function will no longer set that property permanently in the underlying data.

0.1.3

06 Jun 20:21
3fce591
Compare
Choose a tag to compare

Enhancements:

  • #40 - added optional parameter to UserProperty:

    middle_name = UserProperty(str, optional=True)
    

0.1.2

25 May 19:51
3c8cc60
Compare
Choose a tag to compare

Enhancements

  • #28 - added function wysdom.schema to look up an object's schema, allowing jsonschema validation checks in the style
    schema(element).is_valid(instance)
    
  • #33 - JSON schemas are now built using named references, meaning it is now possible to have recursive schemas (e.g. Person objects containing other Person objects)

Bug fixes

  • #30 - object schemas not being correctly rendered as dicts when members of a SchemaArray

Technical changes

  • #31 - new implementations of copy and deepcopy

Documentation

  • #37 - completed initial user guide and API documentation

0.1.1

22 May 12:49
ea31416
Compare
Choose a tag to compare

Add wysdom.schema function for easier access to jsonschema functionality