2

使用pylint版本2.9.02.9.3. 使用2.8.3版,它仍然可以工作。

请参阅提供的链接下的GitHub 问题。

回溯(最近一次通话最后):

  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/inference_tip.py", line 19, in _inference_tip_cached
    return iter(_cache[func, node])
KeyError: (<function register_builtin_transform.<locals>._transform_wrapper at 0x7f310b222700>, <Call l.166 at 0x7f3102ebf970>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.pyenv/versions/3.8.8/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/__init__.py", line 24, in run_pylint
    PylintRun(sys.argv[1:])
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/lint/run.py", line 384, in __init__
    linter.check(args)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 973, in check
    self._check_files(
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1007, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1033, in _check_file
    check_astroid_module(ast_node)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1170, in check_astroid_module
    retval = self._check_astroid_module(
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1215, in _check_astroid_module
    walker.walk(ast_node)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 77, in walk
    self.walk(child)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 74, in walk
    callback(astroid)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/checkers/typecheck.py", line 1071, in visit_assign
    self._check_assignment_from_function_call(node)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/checkers/typecheck.py", line 1081, in _check_assignment_from_function_call
    function_node = safe_infer(node.value.func)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/pylint/checkers/utils.py", line 1177, in safe_infer
    value = next(infer_gen)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/node_classes.py", line 353, in infer
    yield from self._infer(context, **kwargs)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
    yield next(generator)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/decorators.py", line 100, in wrapped
    res = next(generator)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/inference.py", line 299, in infer_attribute
    for owner in self.expr.infer(context):
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/node_classes.py", line 367, in infer
    for i, result in enumerate(generator):
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
    yield next(generator)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/decorators.py", line 100, in wrapped
    res = next(generator)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/bases.py", line 144, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/node_classes.py", line 367, in infer
    for i, result in enumerate(generator):
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
    yield next(generator)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/decorators.py", line 100, in wrapped
    res = next(generator)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/bases.py", line 144, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/node_classes.py", line 343, in infer
    results = tuple(self._explicit_inference(self, context, **kwargs))
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/inference_tip.py", line 21, in _inference_tip_cached
    result = func(*args, **kwargs)
  File "/root/.pyenv/versions/3.8.8/lib/python3.8/site-packages/astroid/brain/brain_builtin_inference.py", line 203, in _transform_wrapper
    if result.col_offset is None:
AttributeError: 'Module' object has no attribute 'col_offset'

requirements.txt测试环境的-文件包含:

astroid
src/packages/project/requirements.txt
pycodestyle
pylint
pylint_junit
pytest
pytest-cov
yapf

包含src/packages/project/requirements.txt

awswrangler==2.8.0
babel==2.9.1
boto3==1.17.77
botocore==1.20.77
category-encoders==2.2.2
joblib==1.0.1
markdown==3.3.4
matplotlib==3.3.4
openpyxl==3.0.7
pandas==1.1.5
pyarrow==4.0.0
pytz==2021.1
requests==2.25.1
scikit-learn==0.24.2
simple_salesforce==1.0.0

编辑产生相同错误的不同尝试:

  1. 安装pylint=2.9.3
  2. 安装astroidpylint(最新版本,无版本规范)
  3. 在构建过程中(在 AWS test-buildspec.yml 中)通过(此处建议)安装astroidpylint升级到最新版本astroidpip install --upgrade astroid
4

2 回答 2

0

看起来您在 pylint 中发现了一个错误/崩溃,您可以在此处2.9打开一个问题。您可以在修复时降级到 2.8.3。

于 2021-07-04T12:39:48.540 回答
0

感谢@Pierre.Sassoulas 的工作,这个问题已经得到解决(见这里)。

在证明以下pylint- 和astroid- 版本组合可以很好地协同工作而不会产生 OP 错误后,已对GitHub 项目进行了新的提交以解决该问题:

pip install pylint==2.9.3
pip install git+git://github.com/PyCQA/astroid.git@c37b6fd47b62486fd6cbe77b913b568b809f1a6d#egg=astroid

从这里开始,在安装最新版本的 pylint 和 astroid 时,应该不会再出现该问题。但是,如果问题再次出现,我会在这里通知您。

于 2021-07-12T07:49:16.853 回答