DEV Community

Cover image for Enhancing Python Code Quality: A Comprehensive Guide to Linting with Ruff

Enhancing Python Code Quality: A Comprehensive Guide to Linting with Ruff

Zoo Codes on July 13, 2023

Introduction In this article, we will discuss the importance of code linting and how to use Ruff to lint your Python code. We will als...
Collapse
 
amal profile image
Amal Shaji • Edited

Can you provide any source/documentation for the Creating custom linting rules in Ruff section. AFAIK, ruff is a binary and it cannot be extended. The ruff python library literally calls the binary.

Collapse
 
ken_mwaura1 profile image
Zoo Codes

read more about rules here: beta.ruff.rs/docs/rules/

Collapse
 
amal profile image
Amal Shaji

This does not address custom linting rules that you wrote. The ruff docs says it does not support plugins. beta.ruff.rs/docs/faq/#can-i-write...

Collapse
 
hartley94 profile image
Martin Thuo

Very informative, 👏.

Collapse
 
ken_mwaura1 profile image
Zoo Codes

Thank you for reading through!

Collapse
 
preethi_prakash profile image
Preethi • Edited

Very Informative ! How do i enable the "highlighting linting errors" in VS Code UI instead of manually running ruff for each file ?

Collapse
 
ken_mwaura1 profile image
Zoo Codes

Thank you for reading through!
Ruff can also be used as a VS Code extension or alongside any other editor through the Ruff LSP.

Collapse
 
adriens profile image
adriens

Thanks for the post, we'll probably give it a try within the very few weeks ;-p

Collapse
 
ken_mwaura1 profile image
Zoo Codes

Awesome let me know how it goes!

Collapse
 
adriens profile image
adriens

Sure, I will 👍

Thread Thread
 
adriens profile image
adriens

💭 BtW : We'll use it throught the GH Action

Thread Thread
 
ken_mwaura1 profile image
Zoo Codes

Thinking about writing a dedicating post on using ruff in Actions.

Thread Thread
 
ken_mwaura1 profile image
Zoo Codes
Collapse
 
hajs profile image
Henning

The section about "Creating custom linting rules in Ruff" sounds too good to be true.
I neither found any documentation nor any code you are referring to..
The issue about a plugin system is still open: github.com/astral-sh/ruff/issues/283

pip install ruff only installs a single binary.

Sounds like a chatgpt halluzination... 😉