mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-13 01:06:03 +00:00
Merge remote-tracking branch 'origin/fix/utils-funcschema-missing-doc' into validation/test-build-with-fixes
# Conflicts: # tests/unit_tests/utils/test_funcschema.py
This commit is contained in:
@@ -83,7 +83,7 @@ def get_func_schema(function: typing.Callable) -> dict:
|
|||||||
|
|
||||||
parameters['properties'][param.name] = {
|
parameters['properties'][param.name] = {
|
||||||
'type': param_type,
|
'type': param_type,
|
||||||
'description': args_doc[param.name],
|
'description': args_doc.get(param.name, ''),
|
||||||
}
|
}
|
||||||
|
|
||||||
# add schema for array
|
# add schema for array
|
||||||
|
|||||||
@@ -188,4 +188,22 @@ class TestGetFuncSchema:
|
|||||||
|
|
||||||
result = funcschema.get_func_schema(doc_func)
|
result = funcschema.get_func_schema(doc_func)
|
||||||
|
|
||||||
assert result['parameters']['properties']['param_name']['description'] == 'This is the param description.'
|
assert result['parameters']['properties']['param_name']['description'] == 'This is the param description.'
|
||||||
|
|
||||||
|
def test_missing_parameter_doc_uses_empty_description(self):
|
||||||
|
"""Test that undocumented parameters do not crash schema generation."""
|
||||||
|
funcschema = get_funcschema_module()
|
||||||
|
|
||||||
|
def partially_documented_func(documented: str, undocumented: int):
|
||||||
|
"""Function with one undocumented param.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
documented: Documented parameter.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
result = funcschema.get_func_schema(partially_documented_func)
|
||||||
|
|
||||||
|
props = result['parameters']['properties']
|
||||||
|
assert props['documented']['description'] == 'Documented parameter.'
|
||||||
|
assert props['undocumented']['description'] == ''
|
||||||
|
|||||||
Reference in New Issue
Block a user