Closed patrick91 closed 3 weeks ago
113,475 additions, 113,475 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
Ouch :sweat_smile:
Yes that's a good idea, we can probably use json.dumps(..., sort_keys=True)
:slightly_smiling_face:
@pawamoy I was using sort_keys, but then the order of the members would change too, not sure why :D
Ah 🤔 I'll investigate. Members order should definitely stay the same. Unless you're using dynamic analysis and inspect.getmembers
doesn't return members in the same order every time 🤔
Can you tell me (again? sorry if I forgot) how you dump and reload the data? Or just point me at the code you're using to dump/load?
I can't replicate the members dis-ordering issue across multiple invocations of Griffe :thinking:
Note that members are dumped in the order they are found in the sources. If you move objects around, the order in the JSON dump will also change :slightly_smiling_face: Maybe we shouldn't do that and sort alphabetically instead, since we either:
By the way this source ordering is completely implicit and relies on default ordering of Python dicts since Python 3.7 (I think it's 3.7).
And if we don't need the initial, implicit order of members, maybe we can even stop using a list and use a dict when dumping them instead :shrug: That would by the way make the JSON more readable (for example, no need to expand an item in Firefox to see the member's name, all names would be displayed right there in the tree without having to expand anything).
Hi there! I have not investigated this much, but looks like using
as_json
doesn't always return the same data (or at least not in the same order) see this diff: https://github.com/strawberry-graphql/strawberry.rocks/commit/fc70f2a1f42c8fd69ce213d8366a71e683be5827For my use case I'll do some sorting, but I was wondering if this could be a feature of Griffe 😊