Changes between Version 69 and Version 70 of pyson


Ignore:
Timestamp:
07/05/23 14:41:29 (17 months ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pyson

    v69 v70  
    6969You 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.
    7070
     71=== Dict Keys
     72Keys of dictionaries/maps are restricted to strings only.
     73To 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
    7175=== Exceptions
    7276Exceptions are handled as follows:
     
    7478Deserialization 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.
    7579
    76 == Annotations
     80== Decorators
    7781
    7882The following annotations are available