pylint和git.exc的奇怪错误

问题描述 投票:0回答:1

给出以下python代码:

import git

try:
    raise git.exc.GitCommandError("dummy", "foo")
except git.exc.GitCommandError as exc:
    print(exc)

直筒抱怨

************* Module test
[...irrelevant errors removed...]
test.py:4:7: E1101: Instance of 'GitError' has no 'GitCommandError' member (no-member)
test.py:4:7: E1101: Instance of 'Exception' has no 'GitCommandError' member (no-member)
test.py:5:7: E1101: Instance of 'Exception' has no 'GitCommandError' member (no-member)
test.py:5:7: E1101: Instance of 'GitError' has no 'GitCommandError' member (no-member)

---------------------------------------------------------------------
Your code has been rated at -36.00/10 (previous run: 4.00/10, -40.00)

代码工作正常,我不理解错误。 git.exc也不例外,而是一个模块:

> python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import git
>>> git.exc
<module 'git.exc' from '/tmp/tmp.ULCyvtUQWx/testenv/lib/python3.5/site-packages/GitPython-2.1.11-py3.5.egg/git/exc.py'>

pylint版本是2.3.1。我想知道这是否只是pylint的错误,还是我遗漏了某些东西...

更新:使用git.GitCommandError而不是git.exc.GitCommandError出于某种原因不会产生相同的错误。即使后者是该类的原始名称。

pylint gitpython
1个回答
0
投票

尝试:from git.exc import GitCommandError,而不只是import git

© www.soinside.com 2019 - 2024. All rights reserved.