Skip to content

Conversation

gnetsanet
Copy link
Contributor

This PR adds a Google-style docstring for Signature.with_instructions
in dspy/signatures/signature.py.

  • Behavior verified in IPython (returns a NEW Signature class with same fields and new instructions).
  • No logic changes; minimal diff.

Marking as draft; I’ll extend to additional Signature methods per #8926.

@gnetsanet gnetsanet changed the title [docs] Add Google-style docstring for Signature.with_instructions #8926 [docs] Add Google-style docstring for Signature.with_instructions #8942 Oct 15, 2025
@okhat
Copy link
Collaborator

okhat commented Oct 15, 2025

Hey this looks great. Why "draft"?

@gnetsanet
Copy link
Contributor Author

gnetsanet commented Oct 15, 2025

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.

Copy link
Collaborator

@chenmoneygithub chenmoneygithub left a 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!

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
Copy link
Collaborator

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

Copy link
Contributor Author

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.

instructions (str): Instruction text to attach to the new signature.
Returns:
type[Signature]: A new Signature class whose fields match ``cls.fields``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, use single backtick

Copy link
Contributor Author

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:
Copy link
Collaborator

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.

Copy link
Contributor Author

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).

@gnetsanet
Copy link
Contributor Author

Closing in favor of #8945 , which includes the requested fixes and a runnable example.

@gnetsanet gnetsanet closed this Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants