From cdf50e2a6906deaba1328835359910542f2ff3fd Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 19 Jul 2019 12:54:22 +0200 Subject: [PATCH] Fix an isue about dict ordering in Python before 3.6. --- jedi/plugins/stdlib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index 025eab59..2460d3e4 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -537,7 +537,10 @@ class DataclassWrapper(ContextWrapper, ClassMixin): for cls in reversed(list(self.py__mro__())): if isinstance(cls, DataclassWrapper): filter_ = cls.get_global_filter() - for name in filter_.values(): + # .values ordering is not guaranteed, at least not in + # Python < 3.6, when dicts where not ordered, which is an + # implementation detail anyway. + for name in sorted(filter_.values(), key=lambda name: name.start_pos): d = name.tree_name.get_definition() annassign = d.children[1] if d.type == 'expr_stmt' and annassign.type == 'annassign':