2017-01-06 6 views
1

現在github3.pyバージョン0.9.6を使用していて、github3.organization(ログイン)関数を呼び出すとエラーが発生します。 :github3 0.9.6 TypeError:pop()は最大1つの引数(2が指定されています)

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) 

私はこの問題を解決するための助けを得ることができたと思います。具体的には、最後の呼び出しでNoneがどこから来たのか不思議です。

事前にお問い合わせいただきありがとうございます。

EDIT1:私は私の場合には組織の総リストよりもはるかに小さいので、すべての組織を反復することはないだろうこれは、ユーザーが提供する既存のORGSのリストに基づいて、特定の組織を起動しようとしていますこの場合私に利益をもたらします(リストが与えられていなければ私のデフォルトのケースになります)。

もう一度おねがいします!

EDIT2:私は、明らかに些細な(プライベート情報を与えることはできません)を実装していたコードのサンプル:

# 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:私はgh.organization機能が原因となっているものであることを知っています私のコードの問題は、スタックトレースに見られるように。私の質問はgithub3のライブラリで、models.pyのpop()関数を解決/修正する方法を尋ねています。これはエラーを投げる関数です。

EDIT4:私はこの問題を解決し、PDBへの感謝:コードを歩いてから は、私は、URLの生成は、組織の機能に与えられた入力に基づく動的であることがわかりました。

具体的には、組織のデータを正しく収集した既定のベースURLでした。私がする必要があったのは、orgのリストとすべてのorgを取得するという条件に基づいて、2つの異なるURLを使用するようにコードを変更することでした。

この問題は解決されました。みんな、ありがとう!

+1

コードを提供できますか? – soundslikeodd

+1

コードとトレースバックを1行与えることは役に立ちません。 'login'とは何ですか? – Leb

+3

何かがdictを期待するリストを得ているように見えます。 – user2357112

答えて

2

問題はorg = gh.organization(needed_org)行にあります。明らかに.organization()メソッドはpopを使用します。 predefined_orgs_listという変数があれば、何らかの並べ替えのリスト(名前から... duh)のように見えます。

しかし、上記のリンクから、popはアイテムではなくインデックスです。この回答Difference between del, remove and pop on listsは、popが使用されていることの素晴らしい例を示し、他の方法と比較しています。

関連する問題