I have this code in (many) of my Python files for a project.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from pprint import pformat
Pylint complains that:
==ook:2
==eek:2
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from pprint import pformat (duplicate-code)
Which while true is utterly irrelevant. The from __future__ [...]
lines are there to prevent compatibility regressions from Python 2 to Python 3. As such, pylint should not complain about them being similar in different files.
Is there a way to stop pytlint doing that?
I know about pylint: disable=duplicate-code
but that will disable it for the whole file because of the import scope. However, I do not want to disable it for the whole file.
Try changing the ignore-imports
in the similarities section of your pylintrc
config file.
Default pylintrc:
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=4
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
# Ignore imports when computing similarities.
ignore-imports=no
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With