-
Couldn't load subscription status.
- Fork 1.2k
Closed
Description
Issue
Some typing in DSL documents appears to be incorrect in Python 3.14. I suspect this is due to the implementation of PEP 649.
The incorrect types break serializing nested documents, as shown in the sample below. This stems from the isinstance(data, collections.abc.Mapping) check in Object._serialize(). There may be other symptoms, I haven't looked elsewhere.
I'm aware the Python client does not yet support 3.14 yet - is there a timeline for when this will be supported?
Reproducible Sample
from elasticsearch.dsl import Document, InnerDoc, mapped_field, Nested
class Child(InnerDoc): ...
class Parent(Document):
children: list[Child] = mapped_field(Nested(Child))
parent = Parent(children=[Child()])
print(f"Parent.children type: {type(parent.children)}")
print(f"Serialized parent child type: {type(parent.to_dict()['children'][0])}")> uv run --python 3.13 es_typing.py
Using CPython 3.13.2 interpreter at: /opt/homebrew/opt/python@3.13/bin/python3.13
Removed virtual environment at: .venv
Creating virtual environment at: .venv
Installed 7 packages in 4ms
Parent.children type: <class 'elasticsearch.dsl.utils.AttrList'>
Serialized parent child type: <class 'dict'>
> uv run --python 3.14 es_typing.py
Using CPython 3.14.0b2
Removed virtual environment at: .venv
Creating virtual environment at: .venv
Installed 7 packages in 4ms
Parent.children type: <class 'dict'>
Serialized parent child type: <class '__main__.Child'>Metadata
Metadata
Assignees
Labels
No labels