Skip to content

lint docs examples #286

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

Merged
merged 2 commits into from
Mar 14, 2025
Merged

Conversation

samuelcolvin
Copy link
Member

Motivation and Context

Many of the examples in th readme were missing imports making them hard to fix.

I've added imports to all examples and also added tests with pytest-examples. (Note: we/I built and maintain pytest-examples).

I presume the fixed imports are relatively uncontroversial, but I welcome feedback on adding pytest-examples.

In other packages we maintain, we also run the examples, e.g. see here which is a lot more work. To get this started, I've avoided running the examples and just linted them with ruff.

How Has This Been Tested?

Yes!

Breaking Changes

NA

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

You should be able to fix linting in examples in future using

uv run pytest tests/test_examples.py --update-examples

Sorry, something went wrong.

dsp-ant
dsp-ant previously approved these changes Mar 14, 2025
Copy link
Member

@dsp-ant dsp-ant left a comment

Choose a reason for hiding this comment

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

This is great! Thank you!

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@samuelcolvin
Copy link
Member Author

Best solution long term would be astral-sh/ruff#3792 when it lands.

@dsp-ant dsp-ant self-requested a review March 14, 2025 11:30
@dsp-ant dsp-ant merged commit 3775916 into modelcontextprotocol:main Mar 14, 2025
4 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.

None yet

2 participants