fix(python): allow attribute access on namespace request dicts

Allows Python namespace implementations to read request dictionary entries as attributes while preserving mapping and `model_dump()` behavior. Missing dunder attributes continue to raise `AttributeError`.

Adds a real namespace connection regression covering list/open operations and omitted optional fields.
This commit is contained in:
Yui Numazawa
2026-11-01 08:01:05 +08:00
committed by GitHub
parent 6da2c68a80
commit faa8953d81
2 changed files with 66 additions and 2 deletions
+5 -1
View File
@@ -70,7 +70,11 @@ fn get_dict_with_model_dump_class(py: Python<'_>) -> PyResult<Bound<'_, PyAny>>
py.run(
c"class DictWithModelDump(dict):
def model_dump(self):
return dict(self)",
return dict(self)
def __getattr__(self, name):
if name.startswith('__'):
raise AttributeError(name)
return self.get(name)",
None,
Some(&locals),
)?;