Skip to content
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

Disabled "line too long"(C0301) not working on docstring comments #2957

Closed
shepster opened this issue Jun 14, 2019 · 5 comments
Closed

Disabled "line too long"(C0301) not working on docstring comments #2957

shepster opened this issue Jun 14, 2019 · 5 comments
Assignees
Labels

Comments

@shepster
Copy link

The following code still generates an error even though "line too long"(C0301) is disabled.

#!/usr/local/bin/python3
"""This is a very long line within a docstring that should trigger a pylint C0301 error line-too-long"""

# pylint: disable=C0301
# pylint: disable=line-too-long

Here is the pylint error

$ pylint dummy.py 
************* Module dummy
dummy.py:2:0: C0301: Line too long (105/100) (line-too-long)

This was talked about previously in issue #1950. The issue was resolved for comments, but it still exists for docstrings.

Using pylint 2.3.1

@hippo91
Copy link
Contributor

hippo91 commented Jun 15, 2019

@shepster i can reproduce it.
You can deactivate the emission of such message just by appending the disable command at the end of the line. For example the following code doesn't trigger any emission:

#!/usr/local/bin/python3
"""This is a very long line within a docstring that should trigger a pylint C0301 error line-too-long"""  # pylint: disable=line-too-long

However i think a bug is present for multiple lines docstrings. When pylint is run against the following code:

#!/usr/local/bin/python3
"""
This is a very very very long line within a docstring that should trigger a pylint C0301 error line-too-long

Even spread on multiple lines, the disable command is still effective on very very very, maybe too much long docstring
"""#pylint: disable=line-too-long

the output is:

************* Module bug_pylint_2957
bug_pylint_2957.py:3:0: C0301: Line too long (108/100) (line-too-long)
bug_pylint_2957.py:5:0: C0301: Line too long (118/100) (line-too-long)

I'll work on this ASAP.

@hippo91 hippo91 self-assigned this Jun 15, 2019
@mcallaghan-bsm
Copy link

The workaround is suffixing any long lines within the docstring with the ignore, but that is QUITE fuggly ...

"""
This is a very very very long line within a docstring that should NOT trigger a pylint C0301 error line-too-long #pylint: disable=line-too-long

some short
lines wouldn't trigger
of course

"""

Even the idea of disabling it for the entire docstring is likely undesired anyway ...

The only legit reason to disable this (IMO) is for URIs that are longer than the project code desired max line length.

@blaiseli
Copy link

The only legit reason to disable this (IMO) is for URIs that are longer than the project code desired max line length.

I have another case in mind: When the docstring contains an example of piece of data, for instance to explain how input data should be structured. Maybe this could also happen for doctests?

@adam-grant-hendry
Copy link
Contributor

With type hinting, methods using arguments with defaults and long package names can go beyond 90-ish characters easily.

@Pierre-Sassoulas
Copy link
Member

There's an option to change the max line length, please search our documentation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants