New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore line-too-long for long URLs #2178
Comments
Have you tried
|
Thank you for your help: I haven't found For references, here is the documentation link: http://pylint.pycqa.org/en/latest/technical_reference/features.html#format-checker-options |
I'm updating this issue because it's the first thing that shows up for the google search "pylint ignore line for long strings". This regex will ignore
^\s*(# )?<?https?://\S+>?$|^\s*(\w*\s*=\s*)?(\"|\').*(\"|\'),?\s*$ |
If you start with the boiler plate via |
How can it be added to pylint? I added it to the
but it didn't help. Btw, the default setting |
Turned out my issue was the default of # TODO:
# do X
# https://github.com/aws/chalice/issues/927#issuecomment-411080600 the last line being 82 chars long, exceeding the 80 character limit. This was fixed by putting the TODO block in triple double quotes or updating the regex to |
|
Things may have changed since you originally posted, but this is now in the standard checkers here: |
This is a feature request.
I have doc comments with URLs in them. Some of these URLs are long (for example canonical Github URLs, with the full commit hash). I want to ignore the
line-too-long
warning for these lines.Steps to reproduce
Current behavior
I get a
line-too-long
error.Expected behavior
Have a good way to locally disable this error (see below).
pylint --version output
1.9.1
The
line-too-long
error is not helpful in this case. The current solutions are either noisy or too extreme.Current solutions
line-too-long
error globally. Either with the CLI flag or with a# pylint: disable=line-too-long
at the top of the file. This is too extreme: I still want to catch code lines that are too long.pylint: disable=...
andpyling: enable=...
directives. This solution does not modify the doc-string or over-extend the line with the URL, but it requires to add two lines of Pylint directives and is very error prone: if you forget/accidentally remove theenable
directive, the content will not be checked.Proposed solutions:
I used other linters in other languages (Javascript, Typescript, C++) and I saw two general ways to handle this kind of issues:
disable-next
directive. This is the mirror image ofdisable
: it ignores errors for the next element instead of the previous one. It allows you to write the directive comment above the failing element. This is also mentioned in this issue. This solution can be applied to other checks, it would also allow you to avoid lines mixing both code and comments (code style),You still have to prefix the failing element, but it's less noisy or error prone.
line-too-long-whitelist-regex
option (better names are welcome). Configure theline-too-long
check with a regex that lets you whitelist some lines. If the regexp matches the line, do not emit the error. For example, I could use a regexp matching URLs but someone else could write its own regexps (I mainly found it used for URLs in other tools). The regexp may fail to distinguish some cases (URL in a doc/comment VS in a string literal) but it's usually good-enough.The text was updated successfully, but these errors were encountered: