Latest Results
Preserve field order when extracting from Pydantic models (#3067)
## Summary
Fixes #3066 - Class fields were being rendered in alphabetical order
instead of declaration order in Python.
This is a follow-up to #1931 which was an incomplete fix. While that PR
correctly changed the `fields` variable to use `IndexMap`, the
extraction from Python still used `BTreeMap<String, PyObject>`, which
sorts keys alphabetically and destroys the original field order before
it reaches the `IndexMap`.
## Changes
- Add `indexmap` feature to pyo3 in
`engine/language_client_python/Cargo.toml`
- Change `BTreeMap` to `IndexMap` when extracting `model_fields` from
Python in `parse_py_type.rs`
- Improved the existing test by using field names (`c`, `b`, `a`) that
would be reordered by alphabetical sorting, making the test actually
catch this class of bugs
## Test plan
- [x] Verified test fails with `BTreeMap` (fields rendered as `a, b, c`)
- [x] Verified test passes with `IndexMap` (fields rendered as `c, b,
a`)
<!-- MENDRAL_SUMMARY -->
---
> [!NOTE]
> Fixes field ordering bug in Pydantic model extraction by replacing
BTreeMap with IndexMap, ensuring fields maintain their declaration order
instead of being alphabetically sorted.
>
> <sup>Written by [Mendral](https://mendral.com) for commit
c25d2ebda497f3536dcd7a005b9dc31b79c7b492.</sup>
<!-- /MENDRAL_SUMMARY --> Active Branches
#3069+80%
#3064-38%
#3027-1%
© 2026 CodSpeed Technology