diff --git a/stone/backends/python_types.py b/stone/backends/python_types.py index 6dc5ea73..eb5e4cd8 100644 --- a/stone/backends/python_types.py +++ b/stone/backends/python_types.py @@ -701,8 +701,10 @@ def _generate_struct_class_custom_annotations(self, ns, data_type): for field in data_type.fields: field_name = fmt_var(field.name, check_reserved=True) - for annotation_type, processor in self._generate_custom_annotation_processors( - ns, field.data_type, field.custom_annotations): + recursive_processors = self._generate_custom_annotation_processors( + ns, field.data_type, field.custom_annotations) + recursive_processors = sorted(recursive_processors, key=lambda x: x[0].name) + for annotation_type, processor in recursive_processors: annotation_class = class_name_for_annotation_type(annotation_type, ns) self.emit('if annotation_type is {}:'.format(annotation_class)) with self.indent(): @@ -991,6 +993,8 @@ def _generate_union_class_custom_annotations(self, ns, data_type): if len(recursive_processors) == 0: continue + recursive_processors = sorted(recursive_processors, key=lambda x: x[0].name) + field_name = fmt_func(field.name) self.emit('if self.is_{}():'.format(field_name)) diff --git a/stone/cli.py b/stone/cli.py index d02fd18a..9192339c 100644 --- a/stone/cli.py +++ b/stone/cli.py @@ -2,7 +2,7 @@ A command-line interface for StoneAPI. """ -import importlib +import importlib.util, importlib.machinery import io import json import logging