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

TypeError: 'NamesConsumer' object does not support indexing #120

Closed
simobasso opened this issue Jan 23, 2018 · 8 comments · Fixed by #121 or jambonrose/django-improved-user#67
Closed

Comments

@simobasso
Copy link
Contributor

simobasso commented Jan 23, 2018

how to reproduce:

freeze

astroid==1.6.1
Django==1.11
isort==4.2.15
lazy-object-proxy==1.3.1
mccabe==0.6.1
pylint==1.8.2
pylint-django==0.8.0
pylint-plugin-utils==0.2.6
pytz==2017.3
six==1.11.0
wrapt==1.10.11

R0201.py

class Foo(object):
    def bar(self, baz):
        return 33

command

pylint --load-plugins=pylint_django  R0201.py

output

No config file found, using default configuration
************* Module R0201
C:  1, 0: Module name "R0201" doesn't conform to snake_case naming style (invalid-name)
C:  1, 0: Missing module docstring (missing-docstring)
C:  1, 0: Missing class docstring (missing-docstring)
C:  2, 4: Black listed name "bar" (blacklisted-name)
C:  2, 4: Black listed name "baz" (blacklisted-name)
C:  2, 4: Missing method docstring (missing-docstring)
W:  2,18: Unused argument 'baz' (unused-argument)
R:  2, 4: Method could be a function (no-self-use)
R:  1, 0: Too few public methods (1/2) (too-few-public-methods)
Traceback (most recent call last):
  File "~/.pyenv/versions/pylint-django-try/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint/__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint/lint.py", line 1347, in __init__
    linter.check(args)
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint/lint.py", line 768, in check
    self._do_check(files_or_modules)
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint/lint.py", line 901, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint/lint.py", line 980, in check_astroid_module
    walker.walk(ast_node)
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint/utils.py", line 1016, in walk
    cb(astroid)
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint_django/augmentations/__init__.py", line 671, in wrap_func
    with_method(orig_method, *args, **kwargs)
  File "~/.pyenv/versions/3.6.3/envs/pylint-django-try/lib/python3.6/site-packages/pylint_django/augmentations/__init__.py", line 290, in ignore_import_warnings_for_related_fields
    iterat = to_consume[0].items if PY3 else to_consume[0].iteritems

expected (as pylint 1.7.5 works)

No config file found, using default configuration
************* Module R0201
C:  1, 0: Missing module docstring (missing-docstring)
C:  1, 0: Missing class docstring (missing-docstring)
C:  2, 4: Black listed name "bar" (blacklisted-name)
C:  2, 4: Black listed name "baz" (blacklisted-name)
C:  2, 4: Missing method docstring (missing-docstring)
W:  2,18: Unused argument 'baz' (unused-argument)
W:  1, 0: Unused variable '__class__' (unused-variable)
R:  2, 4: Method could be a function (no-self-use)
R:  1, 0: Too few public methods (1/2) (too-few-public-methods)

----------------------------------------------------------------------
Your code has been rated at -20.00/10 (previous run: -20.00/10, +0.00)
simobasso added a commit to simobasso/pylint-django that referenced this issue Jan 23, 2018
simobasso added a commit to simobasso/pylint-django that referenced this issue Jan 23, 2018
atodorov pushed a commit that referenced this issue Jan 24, 2018
@nedbat
Copy link

nedbat commented Nov 4, 2018

I'm getting this error with pylint=1.8.4 and pylint-django=0.8.0. I'm on Python 2, so updating to 0.9.0 or beyond is not a possibility yet. Can we get this fix backported to 0.8.0?

@carlio
Copy link
Collaborator

carlio commented Nov 4, 2018

@nedbat for now I am trying to keep a python-2 version at https://github.com/landscapeio/prospector2 and will add it there. Depending on how much it differs, it will either remain a separate project or will become a pull-request onto an old version here perhaps if that is more useful. I haven't tested it much yet though so it is not production ready.

^^ Ignore that, brain fade on my part

@nedbat
Copy link

nedbat commented Nov 4, 2018

@carlio I don't understand how prospector2 relates to pylint-django?

@carlio
Copy link
Collaborator

carlio commented Nov 4, 2018

@nedbat oh sorry. It does not at all. I had too many tabs open and got confused please ignore those comments!

atodorov pushed a commit that referenced this issue Nov 5, 2018
@atodorov
Copy link
Contributor

atodorov commented Nov 5, 2018

I'm getting this error with pylint=1.8.4 and pylint-django=0.8.0. I'm on Python 2, so updating to 0.9.0 or beyond is not a possibility yet. Can we get this fix backported to 0.8.0?

@nedbat can you try the backport_120_to_0.8 branch ? I have cherry-picked the commit that originally fixed this but CI fails because we've dropped testing on Py2 and dependent components already require the latest versions of pylint/astroid.

@nedbat
Copy link

nedbat commented Nov 5, 2018

I cherry-picked the commit onto my own fork (https://github.com/nedbat/pylint-django/tree/nedbat/scopeconsumer) and ran with it, and I didn't get this error.

I did have a separate problem that pylint suddenly stopped in the middle of a large run, though I'm not sure how I'm going to debug that...

@atodorov
Copy link
Contributor

atodorov commented Nov 5, 2018

@nedbat, @carlio I'm not sure what course of action to take here:

  1. We can backport the commit and release a 0.8.1 package which will be completely untested. Otherwise I have to bring back Py2 support to Travis and adjust the versions of dependencies we are compatible with. I did try a quick fix but didn't manage to get it working so not sure how much that would take.

  2. @nedbat you could keep using your own fork until you are able to upgrade. (We can also keep the hotfix branch around claiming it is completely untested). And hopefully the pylint issue can be resolved easily (but not likely).

@nedbat
Copy link

nedbat commented Nov 5, 2018

Thanks, I appreciate the difficulty of maintaining an 0.8.x branch. At this point, we are not moving up to this code anyway until I have time to reproduce and diagnose why pylint stops completely.

atodorov pushed a commit that referenced this issue Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment