Skip to content

Conversation

gnetsanet
Copy link

This PR adds concise Google-style docstrings for four public methods in
dspy/signatures/signature.py:

  • Signature.prepend
  • Signature.append
  • Signature.insert
  • Signature.delete

✅ Verified each method’s behavior in IPython using a local test script
✅ No logic or functional changes

Refs #8944

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! do you want to close #8943 and keep this one open?

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 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``.
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 instructions

Copy link
Collaborator

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.

@gnetsanet gnetsanet force-pushed the docs/signature-docstrings-batch2 branch from 4cb2c09 to 118904b Compare October 18, 2025 21:21
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.

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

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

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

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

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

Choose a reason for hiding this comment

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

unintentional formatting?

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.

2 participants