pylint2 crashes with "unexpected keyword argument 'inline_comment_prefixes'"

Created on 8 Feb 2017  Â·  37Comments  Â·  Source: PyCQA/pylint

python2-pylint 1.6.4.20170104-1 crashes on my machine:

pylint2 python2_script.py

Traceback (most recent call last):
  File "/usr/bin/pylint2", line 11, in <module>
    load_entry_point('pylint==2.0.0', 'console_scripts', 'pylint')()
  File "/usr/lib/python2.7/site-packages/pylint/__init__.py", line 13, in run_pylint
    Run(sys.argv[1:])
  File "/usr/lib/python2.7/site-packages/pylint/lint.py", line 1218, in __init__
    ), option_groups=self.option_groups, pylintrc=self._rcfile)
  File "/usr/lib/python2.7/site-packages/pylint/lint.py", line 434, in __init__
    config_file=pylintrc or config.PYLINTRC)
  File "/usr/lib/python2.7/site-packages/pylint/config.py", line 448, in __init__
    self.reset_parsers(usage, version=version)
  File "/usr/lib/python2.7/site-packages/pylint/config.py", line 462, in reset_parsers
    self.cfgfile_parser = configparser.ConfigParser(inline_comment_prefixes=('#', ';'))
TypeError: __init__() got an unexpected keyword argument 'inline_comment_prefixes'

Well, running simply pylint2 produces the same error.

Most helpful comment

@rogalski @thomasdemoor
Looks like I found a problem. Problem caused by python-future(specifically future==0.14). Upgrade to latest(0.16) "future" solves this problem. In 0.14 they broke configparser import by introducing their own.

All 37 comments

Hello, can you list packages installed in interpreter you are running? It looks like lack of required backport installed (see #1296 for similar case in anaconda).

python2-backports.functools_lru_cache 1.3-1 is installed as well as python2-backports 1.0-1
I have a lot of packages, but help("modules") in python2 gives me an error for some reason and then just hangs...
python3 works without problems though.

help> modules

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
/usr/lib/python2.7/site-packages/matplotlib/cbook.py:137: MatplotlibDeprecationWarning: The matplotlib.delaunay module was deprecated in version 1.4. Use matplotlib.tri.Triangulation instead.
  warnings.warn(message, mplDeprecation, stacklevel=1)
/usr/lib/python2.7/site-packages/matplotlib/__init__.py:1357: UserWarning:  This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)
/usr/lib/python2.7/site-packages/mpltools/style/__init__.py:42: FutureWarning: 

    The style-sheet functionality in mpltools has been integrated into
    Matplotlib >= 1.4. This module will be removed in a future release.

    Note that style-sheets used by `matplotlib.style` use the standard
    Matplotlib rc-file syntax instead of the INI format used by `mpltools`.
    This mostly means un-quoting strings and changing '=' to ':'.


  """, FutureWarning)
/usr/lib/python2.7/site-packages/nltk-3.2-py2.7.egg/nltk/twitter/__init__.py:20: UserWarning: The twython library has not been installed. Some functionality from the twitter package will not be available.
  warnings.warn("The twython library has not been installed. "
** Message: pygobject_register_sinkfunc is deprecated (GstObject)
/usr/lib/python2.7/site-packages/gst-0.10/gst/__init__.py:193: Warning: cannot register existing type 'GstObject'
  from _gst import *
/usr/lib/python2.7/site-packages/gst-0.10/gst/__init__.py:193: Warning: g_once_init_leave: assertion 'result != 0' failed
  from _gst import *
/usr/lib/python2.7/site-packages/gst-0.10/gst/__init__.py:193: Warning: g_type_register_static: assertion 'parent_type > 0' failed
  from _gst import *
/usr/lib/python2.7/site-packages/gst-0.10/gst/__init__.py:193: Warning: interface type 'GstImplementsInterface' or prerequisite type '<invalid>' invalid
  from _gst import *

Sorry, I wasn't precise enough, I was thinking about configparser backport

python2-configparser 3.5.0-1 is also installed :)
I am just wondering if it might be my distro (manjaro) issue. Let me try virtualenv.

UPDATE
ok, in python2 virtualenv everything works. Looks like something is wrong with my system python2 installation, sigh, using package manager and pip interchangeably eventually breaks the system.

I removed python2 completely with all the libs. Installed back python2 and pylint2 and now everything works. Closing.

Same issue for me... 1.6.5 works, 1.7.1 fails.

I'm hitting this trying to upgrade my pylint, and it still happens when using a virtualenv for me.

What is the value of import configparser; configparser.__file__ in environment that fails?

For both it's
~/.virtualenvs/py27/lib/python2.7/site-packages/configparser/__init__.pyc.
However everything works fine in development. It's travisci that fails.

@reubano your 2.7 interpreter uses stdlib from 3.6? That does not sounds right.

However everything works fine in development. It's travisci that fails.

Well, what's the difference between dev env and travis?

I edited the comment... I forgot my main python was 3. As far as what differs... aside from travis running linux vs me running macosx, I'm not really sure.

Seeing this issue as well. Have seen it both with system installed python and brew installed python.

Minimal example (outside of Pylint) that's supposed to trigger an issue. Also, there is a little bit more of introspection in interpreter, which hopefully can help with isolating an issue.

from __future__ import print_function

import sys
import inspect

from configparser import ConfigParser

print("Python version:", sys.version_info)
try:
    print("Signature:", inspect.getargspec(ConfigParser.__init__))
except ValueError:
    print("Signature:", inspect.getfullargspec(ConfigParser.__init__))

print("Module: ", ConfigParser.__module__)
print("Module file: ", inspect.getsourcefile(ConfigParser))
print("Instance: ", ConfigParser(inline_comment_prefixes=('#', ';')))

My outputs (where I cannot reproduce it) are below.

Python 2:

mac-mini:~ rogalski$ python issue1388.py
Python version: sys.version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)
Signature: ArgSpec(args=['self', 'defaults', 'dict_type', 'allow_no_value'], varargs=None, keywords='kwargs', defaults=(None, <class 'collections.OrderedDict'>, False))
Module:  backports.configparser
Module file:  /usr/local/lib/python2.7/site-packages/backports/configparser/__init__.py
Instance:  <backports.configparser.ConfigParser object at 0x10f3082d0>

Python 3:

mac-mini:~ rogalski$ python3 issue1388.py
Python version: sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)
Signature: FullArgSpec(args=['self', 'defaults', 'dict_type', 'allow_no_value'], varargs=None, varkw=None, defaults=(None, <class 'collections.OrderedDict'>, False), kwonlyargs=['delimiters', 'comment_prefixes', 'inline_comment_prefixes', 'strict', 'empty_lines_in_values', 'default_section', 'interpolation', 'converters'], kwonlydefaults={'delimiters': ('=', ':'), 'comment_prefixes': ('#', ';'), 'inline_comment_prefixes': None, 'strict': True, 'empty_lines_in_values': True, 'default_section': 'DEFAULT', 'interpolation': <object object at 0x101b41130>, 'converters': <object object at 0x101b41130>}, annotations={})
Module:  configparser
Module file:  /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py
Instance:  <configparser.ConfigParser object at 0x101be43c8>

On Python 2, inline_comment_prefixes are handles via **kwargs, in Python 3 they are keyword-only arguments. In both interpreters creating an instance of config parser (as you can see) works.

Any progress here? Experiencing exactly the same issue.

@thomasdemoor I'm still yet to reproduce this issue in my local environment. I recently added some code in comments that is supposed to help narrowing down an issue in reporters' environments, but no luck so far. Any help will be appreciated.

@rogalski @thomasdemoor
Looks like I found a problem. Problem caused by python-future(specifically future==0.14). Upgrade to latest(0.16) "future" solves this problem. In 0.14 they broke configparser import by introducing their own.

What’s new in version 0.16.0 (2016-10-27)
This release removes the configparser package as an alias for ConfigParser on Py2 to improve compatibility with Lukasz Langa’s backported configparser package. Previously python-future and the configparser backport clashed, causing various compatibility issues. (Issues #118, #181).

Closed as third-party issue.

Should this not be called out as a dependency in __pkginfo__.py?

Why? Python-Future is not a dependency.

Wysłane z iPhone'a

Dnia 14.05.2017 o godz. 23:35 David Tucker notifications@github.com napisał(a):

Should this not be called out as a dependency in __pkginfo__.py?

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.

I ran into this problem this week. I had recently installed grip, and updated selenium. I don't know which of them caused the issue, but the solution to update future resolved the problem for me.

The problem didn't manifest immediately because I've had a long running emacs session that was finally interrupted by an OSX update. (my Emacs uses pylint during any python editing).

The solution of updating Python-Future pip install --upgrade future worked for me.

@sbko Upgrading to future==0.16.0 did not fix this for me.

Note, there seem to be undocumented dependencies to both the future and futures packages...and these packages are not the same. I was at futures==3.0.1 and was still getting the error even after I upgraded future. When I upgraded to futures==3.1.1, then the error changed to:

backports.configparser.DuplicateOptionError: While reading from 'pylint.rc' [line 26]: option u'ignore' in section u'MASTER' already exists

It seems the config parsing library no longer supports duplicate options like:

# Add <file or directory> to the black list. It should be a base name, not a
# path. You may set this option multiple times.
ignore=CVS

# Ignore all auto-generated South migration directories.
ignore=migrations

This bug should be reopened because I can confirm that upgrading future and futures does fix the problem, so they are hidden dependencies and valid ranges they should be declared.

I disagree, pylint does not import anything from future package. Why should we mention it as dependency?

Dnia 20.06.2017 o godz. 15:09 Sorin Sbarnea notifications@github.com napisał(a):

This bug should be reopened because I can confirm that upgrading future and futures does fix the problem, so they are hidden dependencies and valid ranges they should be declared.

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.

@rogalski Yeah, we are all free to disagree but the reality regarding dependencies can be really tricky, especially for tools. If you look at the full dependency tree I bet you will find those dependencies used somewhere. They don't have to be direct dependencies of pylint and they may even work well with those that are consuming them, still when used via pylint->interm-deps->future(s) the wrong versions may break the library.

In this case they break it really badly on Python 2.7, making the entire tool impossible to use the tool.

In the part I seem people blaming their dependencies for bugs like this. Still, that's not correct because you must be sure that your requirements are safe. Once the culprit is identified the solution is to tune reqs to values that are valid, sometimes using !=1.2.3, or raising minimal version with >=1.2.3.

I think we already have enough proof from multiple users regarding the fact that raising future(s) minimal versions does address the issue.

As a funny note, that's one of the reasons why hacking python package was invented, because there were too many problems caused by various linting tools that were breaking the builds.

PS. I think it may be enough to install newer futures(s) only for py2 if you want.

This begs the question, what does require future or futures? If I use the pipdeptree tool to list all dependences, nothing appears to require either package. If Pylint's not directly requiring them, which of its dependencies is?

@chrisspen that was exactly my point, thanks for claryfing it.

I've posted question on Stack Overflow and will put up a bounty for when eligible.

I didn't had time to investigate yet, for the moment I did manually added those reqs to my package to avoid any build failures.

From my experience there are tools that have weak dependencies that could cause failure, tools not listing deps but using them in one way or another. I will be back when I have more info.

PS. Good idea about SO!

upgrading to future 0.16.0 did the trick... still pylint should declare that it needs future greater than 0.16.0

I ran into this issue as well on with a python 2.7 environment. The issue was that there was conflicting modules of configparser, in my case it was using the incorrect module instead of the backports version so I just removed the incorrect configparser module. I did this by searching the lib directory for configparser and opening each variation of __init__ and or .py file to check which one was correct, obviously the one with the import.backports was the correct one and the one with the that doesn't have 'inline_commment_prefixes' in the __init__ func was the incorrect one.

As @Anthony-Tatowicz reported, what helped me is to delete the folders configparser and configparser-3.5.0.dist-info from the C:\Python27\Lib\site-packages. Then, I could use the pylint of version 1.7.4.

In MacOS Sierra I experimented the same error that solved deleting directory: /usr/local/lib/python2.7/site-packages/future-0.15.2-py2.7.egg/configparser then it worked well.

hello everyone,
please help me solve this error.
i am using django 1.9.5 but installed a new package django-scheduler which is using django 2.0 declarations. So I edited the package's code to suit django 1.9.5 declarations but I have failed to fix this error i get every time i make migrations.
Please help me...
This is the error message i get

(env) swabra@swabra-HP-ProBook-4540s:~/Desktop/kcldocumentation.com/coffee$ python manage.py makemigrations
/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/utils/six.py:808: RemovedInDjango110Warning: SubfieldBase has been deprecated. Use Field.from_db_value instead.
return meta(name, bases, d)

/home/swabra/Desktop/kcldocumentation.com/coffee/cmms/urls.py:39: RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got django.views.static.serve). Pass the callable instead.
urlpatterns.append(url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))

Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(args, *cmd_options)
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(args, *options)
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/core/management/commands/makemigrations.py", line 65, in handle
loader = MigrationLoader(None, ignore_no_migrations=True)
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 170, in build_graph
self.load_disk()
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/django/db/migrations/loader.py", line 105, in load_disk
migration_module = import_module("%s.%s" % (module_name, migration_name))
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in _call_with_frames_removed
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/schedule/migrations/0006_update_text_fields_empty_string.py", line 32, in
class Migration(migrations.Migration):
File "/home/swabra/Desktop/kcldocumentation.com/coffee/env/lib/python3.5/site-packages/schedule/migrations/0006_update_text_fields_empty_string.py", line 39, in Migration
migrations.RunPython(forwards, reverse, elidable=True),
TypeError: __init__() got an unexpected keyword argument 'elidable'

Last version without this problem is pylint == 1.6.5. I use it in VS 2017 with Python 2.7

Same issue here, switched to 1.6.5 because I can't be bother to sift through 100 packages to figure out what is happening.

Solved by @sbko comment: https://github.com/PyCQA/pylint/issues/1318#issuecomment-300897448

Make sure you uninstall any previous version of future before the new version as mentioned here: http://python-future.org/whatsnew.html#what-s-new-in-version-0-16-0-2016-10-27

Hello everyone
I had the same problem, uninstall/reinstall configparser and future did not solve anything.
I finally succeed using pylint by doing this

sudo pip3 install pylint

but i cannot figure why. Any ideas are welcome

Was this page helpful?
0 / 5 - 0 ratings