Skip to content

Conversation

Davshiv20
Copy link
Contributor

This PR adds concise Google-style docstrings for example class

  • Add detailed class-level docstring following Google Python style guide
  • Include comprehensive usage examples showing various initialization patterns
  • Document key features: dictionary-like access, input/output separation, serialization
  • Cover all major use cases: basic usage, dictionary initialization, copying, input/output handling
  • Provide practical examples for common operations like iteration, key checking, and field access

✅ No logic or functional changes

This improves DSPy's docstring coverage and makes the Example class more accessible to users.

This is with reference to the issue #8926

- Add detailed class-level docstring following Google Python style guide
- Include comprehensive usage examples showing various initialization patterns
- Document key features: dictionary-like access, input/output separation, serialization
- Cover all major use cases: basic usage, dictionary initialization, copying, input/output handling
- Provide practical examples for common operations like iteration, key checking, and field access

This improves DSPy's docstring coverage and makes the Example class more accessible to users.
@Davshiv20
Copy link
Contributor Author

@Ziems

@Ziems
Copy link
Collaborator

Ziems commented Oct 16, 2025

Hmm I like this but I'm not the right person to make this decision
@chenmoneygithub wdyt?

@Davshiv20
Copy link
Contributor Author

ah fair enough, my bad @chenmoneygithub

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, this looks pretty good!

Dropped some comments.

- Serialization support for saving/loading examples
- Immutable operations that return new Example instances
Args:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Args should go to the __init__ method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

and provides convenient methods for handling input/output separation, which is crucial
for DSPy's training and evaluation workflows.
Key features:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This section reads a bit strange to me, I suggest just deleting that. "standard data format" should be enough IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have trimmed it down! let me know if i should remove it fully or not?

@Davshiv20
Copy link
Contributor Author

Hey @chenmoneygithub , i've made the fixes as per suggestion and the comments, let me know if I need to make a new PR separately or if we can continue this?

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 updates, LGTM!

@chenmoneygithub chenmoneygithub merged commit bbcfe08 into stanfordnlp:main Oct 17, 2025
10 checks passed
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