Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

TypeError: cannot concatenate 'str' and 'list' objects #28

Closed
anentropic opened this issue Sep 28, 2016 · 2 comments
Closed

TypeError: cannot concatenate 'str' and 'list' objects #28

anentropic opened this issue Sep 28, 2016 · 2 comments

Comments

@anentropic
Copy link

anentropic commented Sep 28, 2016

$ python-codacy-coverage -r target/coverage.xml
Traceback (most recent call last):
  File "/VENV/bin/python-codacy-coverage", line 11, in <module>
    sys.exit(main())
  File "/VENV/lib/python2.7/site-packages/codacy/__init__.py", line 6, in main
    return reporter.run()
  File "/VENV/lib/python2.7/site-packages/codacy/reporter.py", line 189, in run
    logging.error("Coverage report " + args.report + " not found.")
TypeError: cannot concatenate 'str' and 'list' objects
@anentropic
Copy link
Author

the logic here is wrong

def run():
    parser = argparse.ArgumentParser(description='Codacy coverage reporter for Python.')
    parser.add_argument("-r", "--report", help="coverage report file",
                        default=[DEFAULT_REPORT_FILE], type=str,
                        action='append')
    parser.add_argument("-c", "--commit", type=str, help="git commit hash")
    parser.add_argument("-d", "--directory", type=str, help="git top level directory")
    parser.add_argument("-v", "--verbose", help="show debug information", action="store_true")

    args = parser.parse_args()

    if args.verbose:
        logging.Logger.setLevel(logging.getLogger(), logging.DEBUG)

    if not CODACY_PROJECT_TOKEN:
        logging.error("environment variable CODACY_PROJECT_TOKEN is not defined.")
        exit(1)

    if not args.commit:
        args.commit = get_git_revision_hash()

    # Explictly check ALL files before parsing any
    for rfile in args.report:
        if not os.path.isfile(rfile):
            logging.error("Coverage report " + args.report + " not found.")
            exit(1)

Firstly, the logging should be:

logging.error("Coverage report " + rfile + " not found.")

But more importantly, it is failing because my specified path has been appended to [DEFAULT_REPORT_FILE] and the default path doesn't exist. Basically default path should only be added if no user-specified paths are supplied.

I will make a PR

machadoit added a commit that referenced this issue Sep 28, 2016
fix for user-specified paths issue #28
@machadoit
Copy link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants