mercos / codeclimate-pylint

CodeClimate Engine for pylint
MIT License
6 stars 9 forks source link

Python 2 supported? #48

Closed Vadorequest closed 5 years ago

Vadorequest commented 5 years ago

Is python 2 supported?

I followed https://docs.codeclimate.com/docs/pylint and got the following error on Code Climate:

Running pylint using PYTHONPATH: /usr/src/app:/usr/local/lib/python36.zip:/usr/local/lib/python3.6:/usr/local/lib/python3.6/lib-dynload:/usr/local/lib/python3.6/site-packages:/usr/local/lib/python3.6/site-packages/astroid/brain
Traceback (most recent call last):
  File "/usr/src/app/codeclimate-pylint", line 52, in <module>
    Run(files, reporter=CodeClimateReporter(), do_exit=False)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 1394, in __init__
    linter.check(args)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 801, in check
    self._do_check(files_or_modules)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 938, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/usr/local/lib/python3.6/site-packages/pylint/lint.py", line 1018, in check_astroid_module
    walker.walk(ast_node)
  File "/usr/local/lib/python3.6/site-packages/pylint/utils.py", line 1162, in walk
    self.walk(child)
  File "/usr/local/lib/python3.6/site-packages/pylint/utils.py", line 1159, in walk
    cb(astroid)
  File "/usr/local/lib/python3.6/site-packages/pylint_django/checkers/forms.py", line 46, in visit_classdef
    if child.targets[0].name == 'exclude':
AttributeError: 'Subscript' object has no attribute 'name'

I tried to use the following config in my .codeclimate.yml:

plugins:
  pylint: # https://docs.codeclimate.com/docs/pylint
    enabled: true
    channel: "beta"
    plugins:
      - django
    config:
      python_version: 2

But the same error happened. (tried that out of the blue, because that's how radon does https://docs.codeclimate.com/docs/radon)

I'm using python 2.7 with django 1.8.

caiofbpa commented 5 years ago

Python 2 is supported, but pylint runs on Python 3 nevertheless. No additional config is necessary. Here we use pylint to aid us in migrating from Python 2 to 3. Here's an excerpt from our yml:

engines:
  pylint:
    enabled: true
    channel: "beta"

And our .pylintrc:

[MASTER]

py3k=yes

[MESSAGES CONTROL]

disable=W1662

I recommend you disable the Django plugin temporarily to check whether that is part of the problem.

Vadorequest commented 5 years ago

Thanks, it works indeed! (without django plugin)

I suggest to update the doc at https://docs.codeclimate.com/docs/pylint and show the setup for python 2, I was missing the .pylintrc

Edit: Enabling django plugin worked as well, but without any visible change in reported issues