Skip to content
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

Replace pydocstyle with Ruff #1417

Merged
merged 7 commits into from
Aug 1, 2024
Merged

Conversation

eitanturok
Copy link
Contributor

@eitanturok eitanturok commented Aug 1, 2024

This PR lints docstrings using Ruff instead of pydocstyle. It also fixes ~40 style errors that pydocstyle previously did not catch.

This PR removes the dependency on pydocstyle which has been depreciated and is no longer maintained. Instead, we use Ruff, the recommended, drop-in replacement that is much faster and catches bugs pydocstyle misses.

Following the ruff docs, I migrated pydocstyle to ruff. It was pretty simple:

  • I removed pydocstyle from .pre-commit-config.yaml and from pyproject.toml.
  • I took the pydocstyle settings and added them to the [tool.ruff.lint] and [tool.ruff.lint.pycodestyle] parts of pyproject.toml.

To test things out, I installed pre-commit with the new changes and ran pre-commit on all the files in the repo. This caught several errors:

  • Around ~20 docstrings had undocumented parameters where a parameter is in the function but is not documented in the docstring
  • Some docstrings were missing a new line at the end
  • Some docstrings had a return statement that was missing a :
    I believe pydocstyle simply failed to properly detect these errors because it is no longer maintained and ruff simply has a better implementation. I then resolved all of these errors.

Outside of these errors, which are relatively minor, it seems like ruff is enforcing the same format for docstrings as pydocstyle. However, this is not a guarantee that ruff works 100% the same as pydocstyle. I'm not sure if there is a way to test this outside of just running ruff like. I already did. Nonetheless, ruff is much faster and catches formatting errors that pydocstyle misses. So I think we should still switch to using ruff.

Note: There was also a comment in pyproject.toml to migrate pydocstyle to ruff -- this PR is taking care of that.

Eitan Turok added 2 commits August 1, 2024 03:58
@eitanturok eitanturok requested review from a team as code owners August 1, 2024 05:24
@eitanturok eitanturok merged commit ac13217 into mosaicml:main Aug 1, 2024
9 checks passed
@eitanturok eitanturok deleted the eitan-ruff branch August 1, 2024 17:08
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