-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[docs] Add Google-style docstring for Signature.with_instructions #8942 #8943
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
Conversation
Hey this looks great. Why "draft"? |
I initially planned to include multiple methods in this PR but then decided to keep things atomic. Thanks for the review! I’ll keep this PR scoped to with_instructions. I’ll open a follow-up PR for the next methods per #8926. |
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!
dspy/signatures/signature.py
Outdated
def with_instructions(cls, instructions: str) -> type["Signature"]: | ||
"""Return a new Signature class with identical fields and new instructions. | ||
This method does not mutate ``cls``. It constructs a fresh Signature |
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 around variable cls
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.
- Replaced double backticks around cls with single backtick.
dspy/signatures/signature.py
Outdated
instructions (str): Instruction text to attach to the new signature. | ||
Returns: | ||
type[Signature]: A new Signature class whose fields match ``cls.fields`` |
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.
same, use single backtick
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.
- Replaced double backticks around cls with single backtick.
type[Signature]: A new Signature class whose fields match ``cls.fields`` | ||
and whose instructions equal ``instructions``. | ||
Example: |
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 doesn't render on mkdocs, let's use the code block wrapped by triple backtick.
Meanwhile, let's make code example runnable, currently there is no definition of MySig
so the code just breaks.
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.
- Updated docstring example to use triple backtick code block (valid Markdown for mkdocs).
- Added a runnable example (MySig defined explicitly, tested manually and passes).
…ring per style guide
Closing in favor of #8945 , which includes the requested fixes and a runnable example. |
This PR adds a Google-style docstring for
Signature.with_instructions
in
dspy/signatures/signature.py
.Marking as draft; I’ll extend to additional Signature methods per #8926.