-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[docs] Add Google-style docstrings for Signature.prepend/append/insert/delete #8945
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
base: main
Are you sure you want to change the base?
[docs] Add Google-style docstrings for Signature.prepend/append/insert/delete #8945
Conversation
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.
Thanks for the PR! do you want to close #8943 and keep this one open?
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.
Thanks for cleaning up the PR!
This looks good! left some comments
| """Return a new Signature class with identical fields and new instructions. | ||
| This method does not mutate `cls`. It constructs a fresh Signature | ||
| class using the current fields and the provided ``instructions``. |
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.
nit: single backtick instructions
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.
it's still wrapped by double backtick.
…ring per style guide
…rt, and delete; completes Signature class docstrings (fixes issues stanfordnlp#8942 and stanfordnlp#8944)
4cb2c09 to
118904b
Compare
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.
Thank you! this reads pretty good now. Last batch of comments, then we are good to go
| """Return a new Signature class with identical fields and new instructions. | ||
| This method does not mutate `cls`. It constructs a fresh Signature | ||
| class using the current fields and the provided ``instructions``. |
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.
it's still wrapped by double backtick.
| NewSig = MySig.prepend("context", dspy.InputField(desc="Context for translation")) | ||
| print(list(NewSig.fields.keys())) | ||
| assert NewSig is not MySig |
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.
we can remove this assert statement
| """Insert a field at a specific position among inputs or outputs. | ||
| The target section (inputs vs outputs) is determined by | ||
| `field.json_schema_extra["__dspy_field_type"]`. Negative indices are |
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.
"determined by field.json_schema_extra["__dspy_field_type"]" is a bit confusing, it's actually determined by if we pass in InputFieldorOutputField`. We can remote this sentence, since the args section covers it pretty well.
| NewSig = MySig.append("confidence", dspy.OutputField(desc="Translation confidence")) | ||
| print(list(NewSig.fields.keys())) | ||
| assert NewSig is not MySig |
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.
don't need to assert
| @classmethod | ||
| def insert(cls, index: int, name: str, field, type_: type | None = None) -> type["Signature"]: | ||
| def insert( | ||
| cls, index: int, name: str, field, type_: type | None = None |
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.
unintentional formatting?
This PR adds concise Google-style docstrings for four public methods in
dspy/signatures/signature.py:Signature.prependSignature.appendSignature.insertSignature.delete✅ Verified each method’s behavior in IPython using a local test script
✅ No logic or functional changes
Refs #8944