Commits

Evgeniy Tatarkin  committed 3d10de3

fix Item field ordering

  • Participants
  • Parent commits 98cf3b5

Comments (0)

Files changed (1)

File pomp/core/item.py

         # Populate ordered dict
         _args = list(args[:])
         _args.reverse()
+        fields_by_creation_counter = {}
         for field, obj in inspect.getmembers(self.__class__):
             if isinstance(obj, Field):
-                value = _args.pop() if _args else kwargs.get(field, None)
-                super(Item, self).__setitem__(field, value)
+                fields_by_creation_counter[obj.counter] = field
+
+        for key in sorted(fields_by_creation_counter):
+            field = fields_by_creation_counter[key]
+            value = _args.pop() if _args else kwargs.get(field, None)
+            super(Item, self).__setitem__(field, value)
 
     def __setattr__(self, key, value):
         if key in self:
 
 
 class Field(object):
-    pass
+    counter = 0
+
+    def __init__(self):
+        self.counter = Field.counter
+        Field.counter += 1