
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Flake8 plugin for a smart line length validation.
pycodestyle linter (used in Flake8 under the hood by default) already has E501
and W505
rules to validate the line length. flake8-length provides an alternative check that is smarter and more forgiving.
What is allowed:
From linux code style:
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:
Some modern languages even don't have this limitation:
Go has no line length limit. Don't worry about overflowing a punched card.
However, it makes sense to keep some limit to guide developers and keep the alignment reasonable.
Uncle Bob analyzed line length in some popular Java project. The conclusion is it is usually about 45 on average, more than 97 is too much and exceptional.
Raymond Hettinger advises to keep it 90ish. The limit should be about 90 but with reasonable exceptions for when breaking the line would negatively affect the readability.
Kevlin Henney says even 80 is too generous. People read the code following one up-down flow, and breaking the flow with long lines makes the code harder to read.
If you ever had to break a text message to fit in the limit, you know why the plugin exists.
If you're about having as strict limits as possible, flake8-length is on your side. It's better to set 90 chars limit with a few reasonable exceptions rather than have 120 or more chars limit for everything.
Install:
python3 -m pip install --user flake8-length
And check if the plugin is detected by flake8:
flake8 --version
If it doesn't, flake8-length was installed in another python interpreter rather than flake8. You can find the right one:
head -1 $(which flake8)
E501
and W505
), so these checks should be disabled to avoid conflicts with flake8-length.Configuration example (setup.cfg
):
[flake8]
extend-ignore =
E501,
W505
max-line-length = 90
What the limit you should use? I'd say, as small as possible. Try to start with the default one (79) and if you feel it's not enough, extend it to 90. More is too generous.
FAQs
Flake8 plugin for a smart line length validation.
We found that flake8-length demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.