Travis Pylint构建失败,并出现有关singledispatch的错误

时间:2018-08-13 19:31:25

标签: python django travis-ci pylint single-dispatch

我的Travis构建当前在pylint失败,并显示以下错误:

Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.3.6/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/pylint/__init__.py", line 17, in run_pylint
    from pylint.lint import Run
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/pylint/lint.py", line 75, in <module>
    import astroid
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/astroid/__init__.py", line 62, in <module>
    from astroid.nodes import *
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/astroid/nodes.py", line 23, in <module>
    from astroid.node_classes import (
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/astroid/node_classes.py", line 34, in <module>
    from functools import singledispatch as _singledispatch
ImportError: cannot import name singledispatch

我当前用于pylint的构建命令是:

find -name "*.py" -not -path "*/migrations/*" -not -name "apps.py" -not -name "wsgi.py" -not -name "manage.py" | xargs pylint --load-plugins pylint_django

可在我的本地Windows机器上运行(在bash shell中)。我的其余构建脚本是:

language: python

python:
        - "3.3"
        - "3.4"
        - "3.5"
        - "3.5-dev"
        - "3.6"
        - "3.6-dev"
        - "3.7-dev"

install:
        - pip install flake8
        - pip install flake8-docstrings
        - pip install pylint
        - pip install pylint-django
        - pip install -r requirements.txt
        - npm install -g stylelint
        - npm install stylelint-config-standard --save-dev
        - npm install -g eslint
        - npm install -g eslint-config-standard eslint-plugin-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-node

script:
        - flake8 . --exclude migrations,tests.py,__init__.py,apps.py,manage.py
        - find -name "*.py" -not -path "*/migrations/*" -not -name "apps.py" -not -name "wsgi.py" -not -name "manage.py" | xargs pylint --load-plugins pylint_django
    - stylelint **/static/**/*.css
    - eslint . --ignore-pattern '/staticfiles/*'

我应该如何解决该错误? 预先感谢。

1 个答案:

答案 0 :(得分:0)

事实证明,问题是由于flake8干扰了pylint引起的。在构建脚本中交换顺序可以解决问题