【问题标题】:flake8 fails in tox testing environmentflake8 在毒物测试环境中失败
【发布时间】:2021-12-22 08:16:21
【问题描述】:

以下是运行tox 时的失败消息。我没有在任何论坛上看到这个确切的错误报告。 这里的任何指导都会有很大帮助。

我在 3.8-slim-buster docker 容器中调用 tox 并安装了所需的依赖项 - pip install tox flake8 black pylint

错误:

 File ".tox/lint/lib/python3.6/site-packages/hacking/core.py", line 185
    except ImportError, exc:
                      ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

.tox/lint/lib/python3.6/site-packages/flake8/plugins/manager.py", line 168, in load_plugin
    raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "H000" due to invalid syntax (core.py, line 185).

我的 tox.ini 文件。

  [tox]
    minversion = 1.8
    envlist =
        unit
        lint
        format-check
    skipsdist = true
    
    [testenv]
    usedevelop = true
    basepython = python3
    passenv = *
    setenv =
        COVERAGE_FILE={toxworkdir}/.coverage
        PIP_EXTRA_INDEX_URL=https://maven.com/artifactory/api/pypi/simple/
    extras =
        test
    
    [testenv:unit]
    commands =
        python -m pytest {posargs}
    
    [testenv:lint]
    commands =
        python -m flake8
    
    [testenv:format]
    commands =
        python -m black {toxinidir}
    
    [testenv:format-check]
    commands =
        python -m black --diff --check {toxinidir}
    
    [testenv:build-dists-local]
    usedevelop = false
    skip_install = true
    commands =
        python -m pep517.build \
          --source \
          --binary \
          --out-dir {toxinidir}/dist/ \
          {toxinidir}
    
    [testenv:build-dists]
    commands =
        rm -rfv {toxinidir}/dist/
        {[testenv:build-dists-local]commands}
    whitelist_externals =
        rm
    
    [testenv:publish-dists]
    commands =
        bash -c '\
          twine upload {toxinidir}/dist/*.whl \
            -u $TWINE_USERNAME \
            -p $TWINE_PASSWORD \
            --repository-url $TWINE_REPOSITORY \
        '
    whitelist_externals =
        bash
    
    [flake8]
    max-line-length = 100
    format = pylint
    exclude =
        .eggs/
        .tox/,
        .venv*,
        build/,
        dist/,
        doc/,
    #- [H106] Don't put vim configuration in source files.
    #- [H203] Use assertIs(Not)None to check for None.
    #- [H904] Delay string interpolations at logging calls.
    enable-extensions = H106,H203,H904
    ignore = E226,E302,E41
    
    [pytest]
    testpaths = test/
    addopts = -v -rxXs --doctest-modules --cov metarelease --cov-report term-missing --showlocals
    norecursedirs = dist doc build .tox .eggs
    
    [coverage:run]
    omit =
        metarelease/cmd/*
        metarelease/shell.py
    
    [coverage:report]
    fail_under =
        100

【问题讨论】:

  • 您安装了不支持 python 3.x 的极旧版本的 hacking

标签: python python-3.x tox flake8


【解决方案1】:

这既不是flake8 也不是tox 错误,而是hacking 中的错误,当您仔细查看回溯时会注意到。

语法

 File ".tox/lint/lib/python3.6/site-packages/hacking/core.py", line 185
    except ImportError, exc:

仅在 Python 2 中有效,但您使用的是 Python 3。

我以前从未听说过hacking 项目,但使用搜索引擎发现https://pypi.org/project/hacking/

您应该向他们的错误跟踪器报告错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-25
    • 2020-03-16
    • 1970-01-01
    相关资源
    最近更新 更多