grzegorzlyczba opened a new pull request, #2676: URL: https://github.com/apache/thrift/pull/2676
Client: py Default values have a single instance what's fine for non-mutable types, but any change made for list, class, etc are propagated to all instances ``` >>> from gen.test import ttypes >>> b1 = ttypes.B() >>> b1 B(itm=A(value=None)) >>> b1.itm.value = 1 >>> b2 = ttypes.B() >>> b2 B(itm=A(value=None)) >>> b1 B(itm=A(value=1)) >>> ``` With this change, generator will set `None` as default value for such params and add a check in `__init__` method to create new instance when the value is `None`. ```py def __init__(self, itm=None,): if itm is None: itm = A(**{ }) self.itm = itm ``` It works for types defined in the same file, the only limitation is to create recurrence types with a default value of the same type because it generates inf recursion. Apache Jira ticket: https://issues.apache.org/jira/browse/THRIFT-4623 - [x] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? (not required for trivial changes) - [x] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"? - [x] Did you squash your changes to a single commit? (not required, but preferred) - [x] Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"? - [x] If your change does not involve any code, include `[skip ci]` anywhere in the commit message to free up build resources. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@thrift.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org