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

Update cython-lint and replace flake8 with ruff #13699

Merged
merged 5 commits into from
Jul 17, 2023

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented Jul 14, 2023

Description

This PR makes three changes to linting

  • Updates the cython-lint version and fixes associated errors
  • Adds the ruff linter
  • Removes flake8

cython-lint has achieved parity with flake8 for Cython files, so we no longer need flake8 for that. Meanwhile ruff advertises itself as a suitable replacement for flake8 under three conditions: 1) few plugins, 2) using with black, and 3) Python 3 only. All of those apply to cudf code. From a quick analysis, there are a small handful of error codes supported by flake8 (via pyflakes or pycodestyle) that are not yet supported by ruff (pyflakes: F723, F842; pycodstyle: W391,W503, W504, W505, W606). On the flip side, ruff autofixes a range of issues that flake8 can't, it runs more than an order of magnitude faster, it supports more flexible configuration via pyproject.toml, and it promises to replace multiple tools over time. Therefore, I think this is a good switch for us to make.

Note that ruff could in theory also replace isort for Python files, but it does not support Cython yet, so I have left our isort hook in place. We could revisit in the future if that changes.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@vyasr vyasr added code quality Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jul 14, 2023
@vyasr vyasr requested a review from a team as a code owner July 14, 2023 21:19
@vyasr vyasr self-assigned this Jul 14, 2023
@vyasr vyasr requested review from a team as code owners July 14, 2023 21:19
@vyasr vyasr requested review from mroeschke and isVoid July 14, 2023 21:19
@github-actions github-actions bot added CMake CMake build issue ci labels Jul 14, 2023
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

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

Awesome. I’d been wanting to explore this change, thanks for doing so.

.pre-commit-config.yaml Show resolved Hide resolved
python/cudf/cudf/_lib/sort.pyx Show resolved Hide resolved
Copy link
Member

@ajschmidt8 ajschmidt8 left a comment

Choose a reason for hiding this comment

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

Approving ops-codeowner file changes

@vyasr
Copy link
Contributor Author

vyasr commented Jul 17, 2023

/merge

@rapids-bot rapids-bot bot merged commit 89735d8 into rapidsai:branch-23.08 Jul 17, 2023
@vyasr vyasr deleted the feat/ruff branch July 17, 2023 16:42
rapids-bot bot pushed a commit to rapidsai/rmm that referenced this pull request Jul 18, 2023
The cython-lint change is necessary to unblock runs after the Cython 3.0 update, but it is also a QOL improvement that allows us to remove flake8 usage in Cython files since cython-lint now covers a superset of what flake8 could do for Cython. ruff is (nearly) a superset of flake8 for pure Python and has a wide range of advantages, so this switch is beneficial as well. 

cf. rapidsai/cudf#13699

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Ashwin Srinath (https://github.com/shwina)
  - Mark Harris (https://github.com/harrism)

URL: #1302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake CMake build issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants