astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.69k stars 1.09k forks source link

ignores `# fmt: off` for `E501` #14212

Closed beltekylevi closed 3 days ago

beltekylevi commented 3 days ago

A minimal code snippet that reproduces the bug.

# zeus/urls.py
def path(path: str, handler):
    return

def calculate_project_request_proposed_mentors():
    return

urlpatterns = [
    # fmt: off
    path("project-request/<int:project_request_id>/calculate-proposed-mentors/", calculate_project_request_proposed_mentors),  # noqa: E501
    # fmt: on
]

The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.

> poetry run ruff format zeus/urls.py --isolated
1 file reformatted

🙂

def path(path: str, handler):
    return

def calculate_project_request_proposed_mentors():
    return

urlpatterns = [
    # fmt: off
    path(
        "project-request/<int:project_request_id>/calculate-proposed-mentors/",
        calculate_project_request_proposed_mentors,
    ),  # noqa: E501
    # fmt: on
]

The current Ruff settings (any relevant sections from your pyproject.toml).

> pyproject.toml | grep line-length      
line-length = 120

The current Ruff version (ruff --version).


> poetry run ruff --version
ruff 0.7.3
beltekylevi commented 3 days ago
# fmt: off
def path(path: str, handler):
    return

def calculate_project_request_proposed_mentors():
    return

urlpatterns = [
    path("project-request/<int:project_request_id>/calculate-proposed-mentors/", calculate_project_request_proposed_mentors),  # noqa: E501
]
> poetry run ruff format zeus/urls.py       
1 file left unchanged
beltekylevi commented 3 days ago

I'm stupid. But your documentation doesn't emphasize that you are writing examples that are not working. Probably you should improve on that.