codeclimate/codeclimate-duplication

Python 3 syntax error

djetelina opened this issue · 3 comments

Python 3's type annotations seem to throw SyntaxError which results in skipped files:

Skipping file ./tests/test_deck.py due to exception (CC::Engine::Analyzers::ParserError): `python /usr/src/app/lib/cc/engine/analyzers/python/parser.py` exited with code 1:
Traceback (most recent call last):
  File "/usr/src/app/lib/cc/engine/analyzers/python/parser.py", line 34, in <module>
    print json.dumps(to_json(ast.parse(source)))
  File "/usr/lib/python2.7/ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 13
    def __init__(self, name: str, specific_string="abc"):
                           ^
SyntaxError: invalid syntax

Full log: https://codeclimate.com/github/iScrE4m/pyCardDeck/builds/41

Hi @iScrE4m,

The Python parser for this engine was originally written with only Python 2 in mind. In response to this issue, we've added Python 3 support. Please note that you'll need to add a python_version key to your .codeclimate.yml to get the Python 3 parser:

engines:
  duplication:
    enabled: true
    config:
      languages:
        python:
          python_version: 3

I ran this updated version of the engine against your repo at https://github.com/iScrE4m/pyCardDeck locally with that configuration change, and got results I would expect, so I hope this will address your issue.

The updated version of the engine has been released to codeclimate.com, so you should get analysis results there once you update your config. If you're also a CLI user, you'll want to run codeclimate engines:install from your project directory to get the updated engine locally.

I'm going to go ahead and close this issue, but please comment here if you find the issue isn't resolved.

I currently have a languages key for which the value is a sequence of languages:

engines:
  duplication:
    enabled: true
    config:
      languages:
      - ruby
      - javascript
      - python
      - php

How would I adapt the example above to support several languages? Would the updated .codeclimate.yml be

engines:
  duplication:
    enabled: true
    config:
      languages:
        ruby:
        javascript:
        python:
          python_version: 3
        php:

That is, with the sequence of languages replaced by a mapping? (I've also asked this question on Stackoverflow).

HI @khpeek if this is a private repo, can you drop your repo info at www.codeclimate.com/help?

It'll be useful to know:

  • the name of your repo
  • the commit where you tried this

Happy to dig in and take a look 👍 Thanks.