astral-sh / astral-sh/ruff

Provide additional configuration for long-line exemptions (f.ex. via one or many regular expressions)

Open
#5,019 0 comments 10 reactions 0 assignees View on GitHub
configuration
Dominant language
Rust
Stars
49.7k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

Some of our docstrings contain raw HTTP examples:

```
GET /looooooooooooooooooooooooooooooooong/uuuuuuuuuuuuuuuuuuuuurl?arg=foooooooooooo HTTP/1.1
Host: example.com
```

`pylint` provides this via `--ignore-long-lines` (https://pylint.readthedocs.io/en/stable/user_guide/configuration/all-options.html#ignore-long-lines):


---ignore-long-lines

Regexp for a line that is allowed to be longer than the limit.

Default: ^\s*(# )??$

This is already addressed to a degree in #3051 for URLs. Unfortunately this does not cover other valid cases. Those cases are often very domain-specific so it would be nice to have that as a configuration option.

Another example that we run into in our team is docstring examples including SNMP OID paths. They can be very long as well and do not match a URL regex. An example:

```
1.3.6.1.4.1.6527.3.1.2.16.27.1.1.4.14.79.76.79.51.77.98.95.97.114.98.105.116.101.114
```

Having a list of regexes would cover many of such cases. I would suggest having a *list* of regexes instead of a single value. This makes the configuration more readable if you have several patterns.

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests. Start by locating Ruff's long-line checking and configuration parsing, then trace how the existing URL exemption from #3051 is implemented. Done means users can configure one or more regular expressions for additional long-line exemptions, with coverage for the documented HTTP and SNMP OID examples while retaining existing URL behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.