-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python): show properties and values in TypeBuilder string representation #1260
base: canary
Are you sure you want to change the base?
Conversation
@revidious is attempting to deploy a commit to the Gloo Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to 7311baa in 46 seconds
More details
- Looked at
362
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
7
drafted comments based on config settings.
1. engine/language_client_python/python_src/baml_py/type_builder.py:27
- Draft comment:
The docstring should start with a capital letter for consistency and readability.
"""A builder for creating and modifying types at runtime.
- Reason this comment was not posted:
Confidence changes required:10%
The docstring for theTypeBuilder
class is inconsistent in its use of capitalization. It starts with a lowercase letter, which is not standard for Python docstrings. This should be corrected for consistency and readability.
2. engine/language_client_python/python_src/baml_py/type_builder.py:46
- Draft comment:
Remove the extra space between 'the' and 'TypeBuilder'.
"""Initialize the TypeBuilder with optional predefined classes and enums.
- Reason this comment was not posted:
Confidence changes required:10%
The docstring for the__init__
method in theTypeBuilder
class has an extra space between 'the' and 'TypeBuilder'. This is a minor formatting issue but should be corrected for consistency.
3. engine/language_client_python/python_src/baml_py/type_builder.py:64
- Draft comment:
The docstring should start with a capital letter and maintain consistent formatting.
"""A human-readable string representation of the TypeBuilder.
- Reason this comment was not posted:
Confidence changes required:10%
The docstring for the__str__
method in theTypeBuilder
class has inconsistent capitalization and formatting. The first letter should be capitalized, and the formatting should be consistent with other docstrings.
4. engine/language_client_python/python_src/baml_py/type_builder.py:206
- Draft comment:
The docstring should start with a capital letter for consistency.
"""Builder for creating and modifying BAML classes.
- Reason this comment was not posted:
Confidence changes required:10%
The docstring for theNewClassBuilder
class should start with a capital letter for consistency with Python docstring conventions.
5. engine/language_client_python/python_src/baml_py/type_builder.py:248
- Draft comment:
The docstring should start with a capital letter for consistency.
"""Builder for configuring class properties.
- Reason this comment was not posted:
Confidence changes required:10%
The docstring for theClassPropertyBuilder
class should start with a capital letter for consistency with Python docstring conventions.
6. engine/language_client_python/python_src/baml_py/type_builder.py:296
- Draft comment:
The docstring should start with a capital letter for consistency.
"""Builder for creating and modifying BAML enums.
- Reason this comment was not posted:
Confidence changes required:10%
The docstring for theNewEnumBuilder
class should start with a capital letter for consistency with Python docstring conventions.
7. engine/language_client_python/python_src/baml_py/type_builder.py:339
- Draft comment:
The docstring should start with a capital letter for consistency.
"""Builder for configuring enum values.
- Reason this comment was not posted:
Confidence changes required:10%
The docstring for theEnumValueBuilderWrapper
class should start with a capital letter for consistency with Python docstring conventions.
Workflow ID: wflow_RO6UccrIdJ6lPCDD
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
nice work! We'll have someone in the team review soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@revidious this is really great work, but if possible, would you be ok implenting this in rust instead?
otherwise we'll have different printers in python/ts/ruby/etc and will make it harder to catch bugs later on (and small details will easily be missed)
7311baa
to
2974458
Compare
…mplementation for TypeBuilder and related structs - Add Python bindings for string representation - Add comprehensive test cases for both Rust and Python - Add detailed documentation for string formatting
@hellovai Done! I've moved the implementation to Rust with the Display trait, and Python now just exposes it via str. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great! :) ready to merge. small request, could you add this for the language_client_{ts / ruby} as well. If not, let us know and i'll follow up on it instead. This is almost perfect btw 👍
Some nits things I would do (but not mandatory):
- add whitespace / newlines in the rendered string
- instead of
BamlValue::to_string(...)
I would just implement the display for all baml values - Instead of hard-coding which attributes i print out for meta, i would inject all metas in the print out, not just alias / description
…ay all metadata fields
Thanks for the feedback! I've implemented all three suggestions:
Changes are implemented in both TypeScript and Ruby clients as well (what it seems like). |
This PR enhances the TypeBuilder's string representation to show all properties of a class and values of an enum, including their aliases and descriptions.
Changes:
Show all properties in class representation:
Show all values in enum representation:
Store and track metadata:
Fixes #1253