Closed
Description
Rule request
Thesis
- Validate that code line not longer than N chars. Looks like 89.5 chars is a convention for now (one, two).
- Allow lines longer than N chars if the part after N chars contains only a string and optional comma.
- Maybe, even such lines should be limited. For instance, not to get longer than 120 chars. However, this part can be validated by flake8
max-line-length
without any effort from us.
Example:
d = {
# it is ok
'one': 'some really long message that goes beyond 90 chars',
}
Reasoning
Statements longer than 80 columns will be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information. <...> However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them.
I see a lot of Python code that does some awful breaks to fit long text messages into the project's line limit just because. However, it creates a lot of difficulties:
- Difficult to grep.
- Easy to miss a space on the string breaks.
- It doesn't make code more readable at all, even decreases readability. In most cases, I don't care if the ending of an error message goes outside of my screen.
After all, it's good to relax a rule that looks not so reasonable in the modern world:
Go has no line length limit. Don't worry about overflowing a punched card.