Changes between Version 69 and Version 70 of pyson
- Timestamp:
- 07/05/23 14:41:29 (17 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
pyson
v69 v70 69 69 You can use {{{ Union[X, NoneType] }}} where {{{NoneType=type(None)}}} or {{{Optional[X]}}}if the object can also be None. So for exmple you can use {{{reservationBid:Union[Bid,type(None)] = None}}}. Do not use the mypy.NoneType which is an entirely different class. We do not support {{{ Union[X,Y] }}} where both X and Y are not NoneType. 70 70 71 === Dict Keys 72 Keys of dictionaries/maps are restricted to strings only. 73 To work around this restriction, pyson recognises from your specified type (eg {{{Dict[MyObject, str]}}}) whether the key is an object. In that case, the string key in the json dict is assumed to contain a string that can be parsed as json. The string is thus parsed as json object, and then further parsed as MyObject as usual. 74 71 75 === Exceptions 72 76 Exceptions are handled as follows: … … 74 78 Deserialization takes a dict with at least a "message" field. The constructor of the provided class is called with this message, so make sure that your exception constructor takes the message as the constructor argument. If the dict contains a cause, the cause is also parsed recursively, as general Exception, and attribute {{{__cause__}}} of the exception is filled with the result. 75 79 76 == Annotations80 == Decorators 77 81 78 82 The following annotations are available