typesystem icon indicating copy to clipboard operation
typesystem copied to clipboard

drop Field._creation_counter?

Open wbolster opened this issue 5 years ago • 2 comments

i admit i do not understand completely what's going on, but the Field._creation_counter seems like a hack to me, and i wonder why it's necessary?

since python 3.6, dictionaries retain insertion order which, iiuc, means the attrs passed to __new__ are in source code order already.

why not assign all fields to __schematype_fields__ instead and use that when ordering is needed?

while looking at it, parent schema fields are included in child schema, but does schematype handle overrides of fields correctly at all? the attrs project has some code that may be relevant to look at here, since it deals with similar problems: https://github.com/python-attrs/attrs/blob/4fe28966e88b9b85c9c2df77ffb34f70175c4492/src/attr/_make.py#L351-L362

wbolster avatar Mar 08 '19 17:03 wbolster

since python 3.6, dictionaries retain insertion order which, iiuc, means the attrs passed to new are in source code order already.

Okay... if we can demonstrate in a test case that the field ordering matches the source code ordering, then I'm 100% happy to drop it, yup!

tomchristie avatar Mar 08 '19 18:03 tomchristie

parent schema fields are included in child schema, but does schematype handle overrides of fields correctly at all?

Believe so, yup. Fairly sure there's a test case for exactly that, but worth double checking.

tomchristie avatar Mar 08 '19 18:03 tomchristie