Skip to content

[BE]: Add ruff to lintrunner - use for additional plugins like pyupgrade etc. #94737

@Skylion007

Description

@Skylion007

🚀 The feature, motivation and pitch

  • The PyTorch codebase is huge. Formatting and linting the repo takes a lot of time. Additionally, adding new linters is a bit of challenge. https://github.com/charliermarsh/ruff is a Rust linter/fixer that implements rules for the most common of flake8 linters (pyupgrade, flake8, isort, popular flake8-plugins etc). Many of our existing linters can be combined here. The only downside is that it does reduce the number of flake8-plugins we can use (since they are all reimplemented in the framework), but it does many of the autofixes. Even if we don't replace flake8 etc with this plugin, we can use it supplement it, by using it only for other modules like pyupgrade (where you can select individual pyupgrade rules etc.). I've been using to implement various PRs and it's pretty reasonable so far. See Consider upgrade to Python 3.8+ syntax with pyupgrade #94040

Alternatives

Keep the existing linters

Additional context

It's also really, really fast!

cc @malfet @seemethere

Metadata

Metadata

Assignees

Labels

better-engineeringRelatively self-contained tasks for better engineering contributorsenhancementNot as big of a feature, but technically not a bug. Should be easy to fixmodule: buildBuild system issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions