Skip to content

Commit 5a521a8

Browse files
committed
switch last_key method for mapping
1 parent 6478dba commit 5a521a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/input/input_python.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,14 @@ impl<'py> ValidatedDict<'py> for GenericPyMapping<'_, 'py> {
827827
fn last_key(&self) -> Option<Self::Key<'_>> {
828828
match self {
829829
Self::Dict(dict) => dict.keys().iter().last(),
830-
Self::Mapping(mapping) => mapping.keys().ok()?.iter().ok()?.last()?.ok(),
830+
// see https://github.com/pydantic/pydantic-core/pull/1512#discussion_r1826057970
831+
Self::Mapping(mapping) => mapping
832+
.call_method0(intern!(mapping.py(), "keys"))
833+
.ok()?
834+
.iter()
835+
.ok()?
836+
.last()?
837+
.ok(),
831838
Self::GetAttr(_, _) => None,
832839
}
833840
}

0 commit comments

Comments
 (0)