Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up Ruff (Python Linter)

As far as I understood ruff implements pycodestyle rules by default. However, when I run my code through pycodestyle I get:

test.py:5:1: E302 expected 2 blank lines, found 1
test.py:8:1: E302 expected 2 blank lines, found 1
test.py:13:9: E129 visually indented line with same indent as next logical line
test.py:22:1: E305 expected 2 blank lines after class or function definition, found 1
test.py:32:5: E265 block comment should start with '# '
test.py:34:5: E265 block comment should start with '# '
test.py:43:14: W292 no newline at end of file

While ruff gives me all good.

Anyone can tell me why that is the case?

like image 498
SrdjaNo1 Avatar asked Sep 06 '25 08:09

SrdjaNo1


1 Answers

As it says in documentation:

By default, Ruff enables Flake8's F rules, along with a subset of the E rules

To capture all pydocstyle rules (E, W), you should configure ruff in pyproject.toml as follows:

[tool.ruff.lint]
extend-select = ["W", "E"]
preview = true
like image 56
Bekzod Avatar answered Sep 07 '25 23:09

Bekzod