Klaus Foerster
2010-07-18 17:31:25 UTC
Hi,
I have a small example code snippet with two pylint warnings:
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
i_want_to_mask_this_warning = value_with_long_name +
value_with_long_name
iwant_to_see_this_warning = 7
print value_with_long_name
Now I would like to supress a pylint warning specifically for one line
The solution seems to be to add a trailing comment like for example
# pylint: disable=W0612
So my code would look like:
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
i_want_to_mask_this_warning = value_with_long_name +
value_with_long_name # pylint: disable=W0612
iwant_to_see_this_warning = 7
print value_with_long_name
Now the next two problems arise.
- I get a pylint warning because my line is too long
- my line IS too long, and if I masked the line too long warning it
would become even longer.
The next thing I tried was to use a backslash to shorten my line and
move the pylint warning to the next line
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
i_want_to_mask_this_warning = value_with_long_name +
value_with_long_name \
# pylint: disable=W0612
iwant_to_see_this_warning = 7
print value_with_long_name
However this does not work as expected.
it's now the rest of the function, which will ignore pylint warnings,
but not my single line.
Is there a suggested idiom to ignore warnings for long lines ?
For my given example I found a working but not really elegant solution,
which is:
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
( i_want_to_mask_this_warning # pylint: disable=W0612
) = value_with_long_name + value_with_long_name
iwant_to_see_this_warning = 7
print value_with_long_name
perhaps one solution would be something like:
# pylint: disable_for_next_line=W0612
i_want_to_mask_this_warning = value_with_long_name + value_with_long_name
Thanks in advance for other suggestions / ideas?
I have a small example code snippet with two pylint warnings:
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
i_want_to_mask_this_warning = value_with_long_name +
value_with_long_name
iwant_to_see_this_warning = 7
print value_with_long_name
Now I would like to supress a pylint warning specifically for one line
The solution seems to be to add a trailing comment like for example
# pylint: disable=W0612
So my code would look like:
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
i_want_to_mask_this_warning = value_with_long_name +
value_with_long_name # pylint: disable=W0612
iwant_to_see_this_warning = 7
print value_with_long_name
Now the next two problems arise.
- I get a pylint warning because my line is too long
- my line IS too long, and if I masked the line too long warning it
would become even longer.
The next thing I tried was to use a backslash to shorten my line and
move the pylint warning to the next line
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
i_want_to_mask_this_warning = value_with_long_name +
value_with_long_name \
# pylint: disable=W0612
iwant_to_see_this_warning = 7
print value_with_long_name
However this does not work as expected.
it's now the rest of the function, which will ignore pylint warnings,
but not my single line.
Is there a suggested idiom to ignore warnings for long lines ?
For my given example I found a working but not really elegant solution,
which is:
""" simple pylint example """
def afunc(value_with_long_name):
""" a doc string """
value_with_long_name = 3
( i_want_to_mask_this_warning # pylint: disable=W0612
) = value_with_long_name + value_with_long_name
iwant_to_see_this_warning = 7
print value_with_long_name
perhaps one solution would be something like:
# pylint: disable_for_next_line=W0612
i_want_to_mask_this_warning = value_with_long_name + value_with_long_name
Thanks in advance for other suggestions / ideas?