feat: add docstring enrichment, default values, re-exports#2592
Draft
andeplane wants to merge 1 commit into
Draft
feat: add docstring enrichment, default values, re-exports#2592andeplane wants to merge 1 commit into
andeplane wants to merge 1 commit into
Conversation
Completes the extract_function_schema feature: - _parse_docstring: parses Google-style docstrings via griffe to set description fields; appends cognite-query-id guidance suffix to DataFrame params; raises ValueError for unknown docstring params - _apply_default_value: coerces ast.unparse'd defaults to the correct Python type (str via literal_eval, int/float cast, bool via == "True") - _parse_single_annotation: wired to apply defaults for all param types - __init__.py: re-exports extract_function_schema, SchemaResult, ErrorResult Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_parse_docstring: parses Google-style docstrings viagriffeto populatedescriptionon schema properties; appends acognite-query-idguidance suffix to DataFrame params; returnsErrorResultfor unknown docstring params_apply_default_value: coercesast.unparsestrings to correct Python types (strvialiteral_eval,int/floatcast,boolvia== "True"); rejects defaults for list and non-primitive typesextract_function_schema,SchemaResult,ErrorResultfromcognite.client._api.aiChanges
cognite/client/_api/ai/python_schema.py—_parse_docstring(full),_apply_default_value, wired into_parse_single_annotationcognite/client/_api/ai/__init__.py— re-exportstests/tests_unit/test_api/test_python_schema.py— 14 new tests (@pytest.mark.us3)Test plan
pytest tests/tests_unit/test_api/test_python_schema.py— all 46 greenpython_schema.py(actual: 98%)mypy cognite/client/_api/ai/python_schema.py— cleanruff check cognite/client/_api/ai/python_schema.py— cleanStack
🤖 Generated with Claude Code