How to solve: AttributeError: 'FunctionInfo' object has no attribute 'fan_in' error in pydriller?
How to solve: AttributeError: 'FunctionInfo' object has no attribute 'fan_in' error in pydriller?
我正在使用 pydriller 检索提交信息,但出现错误“AttributeError:'FunctionInfo' 对象没有属性 'fan_in'。你有什么解决办法吗?
执行代码-
from pydriller import RepositoryMining
for commit in RepositoryMining (path_to_repo='https://github.com/openssl/openssl', only_commits=['9cedfc90cebc905b20275d534699a1070bba65a4']).traverse_commits():
commit_row = {
'hash': str(commit.hash),
'msg': str(commit.msg),
'author_date': str(commit.author_date),
'merge': str(commit.merge),
'dmm_unit_size': str(commit.dmm_unit_size)
}
print(commit_row)
我得到以下错误输出:-
Traceback (most recent call last):
File "/Volumes/GoogleDrive/Shared drives/guru_shared/guru_research/CVE-code-extraction/Code/example_extraction.py", line 30, in <module>
'dmm_unit_size': str(commit.dmm_unit_size)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 687, in dmm_unit_size
return self._delta_maintainability(DMMProperty.UNIT_SIZE)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 735, in _delta_maintainability
delta_profile = self._delta_risk_profile(dmm_prop)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 752, in _delta_risk_profile
deltas = [mod._delta_risk_profile(dmm_prop) for mod in supported_modifications]
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 752, in <listcomp>
deltas = [mod._delta_risk_profile(dmm_prop) for mod in supported_modifications]
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 386, in _delta_risk_profile
low_before, high_before = self._risk_profile(self.methods_before, dmm_prop)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 336, in methods_before
self._calculate_metrics(include_before=True)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 406, in _calculate_metrics
self._function_list.append(Method(func))
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 80, in __init__
self.fan_in = func.fan_in
AttributeError: 'FunctionInfo' object has no attribute 'fan_in'
我找到了问题的原因,这与解释器的问题有关。我在IDE.
中将Python解释器改成3.8版本后问题解决
我正在使用 pydriller 检索提交信息,但出现错误“AttributeError:'FunctionInfo' 对象没有属性 'fan_in'。你有什么解决办法吗?
执行代码-
from pydriller import RepositoryMining
for commit in RepositoryMining (path_to_repo='https://github.com/openssl/openssl', only_commits=['9cedfc90cebc905b20275d534699a1070bba65a4']).traverse_commits():
commit_row = {
'hash': str(commit.hash),
'msg': str(commit.msg),
'author_date': str(commit.author_date),
'merge': str(commit.merge),
'dmm_unit_size': str(commit.dmm_unit_size)
}
print(commit_row)
我得到以下错误输出:-
Traceback (most recent call last):
File "/Volumes/GoogleDrive/Shared drives/guru_shared/guru_research/CVE-code-extraction/Code/example_extraction.py", line 30, in <module>
'dmm_unit_size': str(commit.dmm_unit_size)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 687, in dmm_unit_size
return self._delta_maintainability(DMMProperty.UNIT_SIZE)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 735, in _delta_maintainability
delta_profile = self._delta_risk_profile(dmm_prop)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 752, in _delta_risk_profile
deltas = [mod._delta_risk_profile(dmm_prop) for mod in supported_modifications]
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 752, in <listcomp>
deltas = [mod._delta_risk_profile(dmm_prop) for mod in supported_modifications]
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 386, in _delta_risk_profile
low_before, high_before = self._risk_profile(self.methods_before, dmm_prop)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 336, in methods_before
self._calculate_metrics(include_before=True)
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 406, in _calculate_metrics
self._function_list.append(Method(func))
File "/usr/local/lib/python3.8/site-packages/pydriller/domain/commit.py", line 80, in __init__
self.fan_in = func.fan_in
AttributeError: 'FunctionInfo' object has no attribute 'fan_in'
我找到了问题的原因,这与解释器的问题有关。我在IDE.
中将Python解释器改成3.8版本后问题解决