我当前使用的是github3.py版本0.9.6,在调用github3.organization(login)函数时收到一个错误:
Traceback (most recent call last):
File "Main.py", line 23, in <module>
__main__()
File "Main.py", line 19, in __main__
Stats.git_auth(username, password, access_token)
File "/Users/edigiovine/Repositories/GitMetrics/Stats.py", line 36, in git_auth
git_orgs(gh)
File "/Users/edigiovine/Repositories/GitMetrics/Stats.py", line 49, in git_orgs
org = gh.organization(rel_org)
File "/Library/Python/2.7/site-packages/github3/github.py", line 971, in organization
return Organization(json, self) if json else None
File "/Library/Python/2.7/site-packages/github3/orgs.py", line 236, in __init__
super(Organization, self).__init__(org, session)
File "/Library/Python/2.7/site-packages/github3/models.py", line 311, in __init__
super(BaseAccount, self).__init__(acct, session)
File "/Library/Python/2.7/site-packages/github3/models.py", line 77, in __init__
super(GitHubCore, self).__init__(json)
File "/Library/Python/2.7/site-packages/github3/models.py", line 30, in __init__
self.etag = json.pop('ETag', None)
TypeError: pop() takes at most 1 argument (2 given)
我希望我能得到一些帮助来解决这个问题。具体地说,我很好奇最后一次通话中的“无”从何而来。在
提前感谢您的帮助!在
EDIT1:我试图根据用户提供的现有组织的列表来调用特定的组织,在我的例子中,这个列表比组织的总列表要小得多,所以在这种情况下,遍历所有组织对我没有好处(如果没有给出列表,这是我的默认情况)。在
再次感谢!在
EDIT2:我正在实现的代码示例,显然微不足道(无法提供私有信息):
^{pr2}$编辑3:我知道gh.组织函数是导致代码中出现问题的原因,堆栈跟踪可以看出这一点。我的问题是关于github3的库,并询问如何解决/修复中的pop()函数模型.py,它是引发错误的函数。在
EDIT4:多亏了pdb,我解决了这个问题: 通过浏览代码,我发现url生成是基于组织函数的输入动态生成的。在
具体地说,我所拥有的是我们组织的默认基本url,它正确地收集了我们的组织数据。我的组织需要修改两个组织的代码。在
这个问题现在解决了。谢谢大家!在
就记录而言,当您期望一个dict并希望使用
.pop(key, None)
清除它,但在列表中使用它时,也会发生这种情况。对于列表,.pop()
总是只接受一个参数。在问题出在您的} 。无论
org = gh.organization(needed_org)
行中。显然.organization()
方法使用了^{predefined_orgs_list
变量是什么,看起来都像某种类型的列表(来自名称…duh)。在但是从上面的链接,
pop
接受的是索引而不是项。这个答案Difference between del, remove and pop on lists展示了pop
的用途,并将其与其他方法进行了比较。在相关问题 更多 >
编程相关推荐