No warnings 'too-many-blank-lines' or 'blank-line-between-methods'.
cdar opened this issue · comments
Thank you for the project!
There are no wornings about blank lines (missing, present). Am I missing something?
Are there any tests for that?
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install ruff
$ ruff --version
ruff 0.4.3
$ cat <<EOF > test.py
> from enum import Enum
from itertools import dau
def a():
pass
def b():
pass
class Failure(Enum):
pass
EOF
$ ruff check test.py
test.py:2:23: F401 [*] `itertools.dau` imported but unused
Found 1 error.
[*] 1 fixable with the `--fix` option.
search keywords: no blank lines
The blank line rules are preview only rules and not enabled by default. You need to run ruff check --extend-select E3 --preview test.py
@MichaReiser I have a question that seems related to this. What I'm seeing is that the formatter wants to remove blank lines but the checker doesn't inform about the same lines. So in pre-commit/CI ruff check
isn't noticing changes that ruff format
would do automatically.
When Django creates migrations it inserts a blank line after the class
header before the dependencies
:
# Generated by Django 4.2.11 on 2024-05-15 08:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
...
]
operations = [
...
]
If I run ruff check path/to/migration_file.py
(I have preview = true
and E3
in pyproject.toml
) it just tells me All checks passed!
. But if I run ruff format ruff check path/to/migration_file.py
I get 1 file reformatted
and it has removed the blank line.
Isn't ruff check
supposed to tell me about all changes ruff format
would do? Is there some other rule I need to enable?
Isn't ruff check supposed to tell me about all changes ruff format would do? Is there some other rule I need to enable?
It's our long-term goal that ruff check
performs all necessary checks, that includes linting, formatting, type checking etc. However, we aren't there yet and ruff check
only runs the lint rules today.
You have to run ruff format --check
to verify if all files are correctly formatted (it also has a --diff
option if you want to get a diagnostic for differences)