Reputation: 31
I am currently using github3.py version 0.9.6, and am receiving an error upon invoking the github3.organization(login) function:
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)
I was hoping I could receive some help with resolving this issue. Specifically, I am curious as to where the None comes from in the last call.
Thanks for any help in advance!
EDIT1: I am trying to invoke particular organizations based on a list of existing orgs provided by a user, which in my case is much smaller than the total list of organizations, so iterating over all organizations would not be a benefit to me in this case (which happens to be my default case if a list is not given).
Thanks again!
EDIT2: A sample of the code I am implementing, obviously trivial (cannot give private info):
# Defined username, password, access_token, and api_call_base in a
# config file, use them here to build the github object.
gh = github3.login(username, password, access_token, api_call_base)
# predefined_orgs_list is a list of the names of the organizations
# that are in focus for my project.
for needed_org in predefined_orgs_list:
# This is the function that throws the error I am receiving.
org = gh.organization(needed_org)
# If above function works, then the following value should be
# the same as in the predefined_orgs_list
print org.login
EDIT3: I know that the gh.organization function is what is causing the problem in my code, as can be seen by the stack trace. What my question is pertaining to is the library for github3 and asking how I resolve/fix the pop() function in models.py, which is the function throwing the error.
EDIT4: I resolved this issue, thanks to pdb: from walking through the code, I found that the url generation is dynamic based on the inputs given to the organization function.
Specifically, what I had was a default base url to our organizations that correctly gathered our organization data. What I needed to do was modify my code to use two different urls, based on the condition of being given a list of orgs vs. grabbing all orgs.
This issue is now resolved. Thanks everyone!
Upvotes: 3
Views: 10751
Reputation: 512
Just for the record, it also happens when you expect a dict and want to clear it using .pop(key, None)
but use it on a list instead. For a list, .pop()
always takes only one argument.
Upvotes: 11
Reputation: 15953
The problem lies in your org = gh.organization(needed_org)
line. Apparently .organization()
method uses pop
. Whatever predefined_orgs_list
variable might be, looks like a list (from the name ...duh) of some sort.
However from the link above, pop
takes an index not an item. This answer Difference between del, remove and pop on lists shown a great example of what pop
is used for and compares it to other methods.
Upvotes: 2