Getting started with Ruff and Poetry

I manage most of my Python projects with Poetry, I really like how it handles dependencies, configures projects and manages virtual environments using simple commands.

Normally I include linting tools as part of my Poetry projects, specifically flake8 and pylint. They served me well, but recently I saw a lot of hype around ruff in online tech circles, so I decided to give it a try.

And I'm glad I did, ruff and poetry are a match made in heaven. I'm really enjoying working with ruff, and how I can have really good static code analysis, and really fast.

In this article, I give a quick guide on how to setup ruff the way I use it on my Python projects, and how to integrate the ruff-lsp to Neovim.

Add ruff to you poetry dependencies

Assuming you already have a poetry project in place, you can add ruff as a development dependency:

poetry add --group dev ruff

This will create the following entry in your pyproject.toml file:

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.2"

Configure ruff

The ruff documentation is pretty good, and the tool is pretty versatible, so you can set ruff to however you like …

more ...