Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github.search_topics returning list of repos that throw an error when trying to fetch undefined data #929

Closed
men1n2 opened this issue Oct 12, 2018 · 6 comments

Comments

@men1n2
Copy link

men1n2 commented Oct 12, 2018

Hello,

I was trying to fetch a list of repositories with a specific topic and then play with the returned attributes, but the Repository objects returned in the PaginatedList throw an error when trying to fetch unknown data:

Traceback (most recent call last):
  File "github-crawler.py", line 6, in <module>
    print(i, repo.archive_url)
  File "/home/user/.local/lib/python3.6/site-packages/github/Repository.py", line 2407, in get_topics
    self.url + "/topics",
  File "/home/user/.local/lib/python3.6/site-packages/github/Repository.py", line 745, in url
    self._completeIfNotSet(self._url)
  File "/home/user/.local/lib/python3.6/site-packages/github/GithubObject.py", line 259, in _completeIfNotSet
    self._completeIfNeeded()
  File "/home/user/.local/lib/python3.6/site-packages/github/GithubObject.py", line 263, in _completeIfNeeded
    self.__complete()
  File "/home/user/.local/lib/python3.6/site-packages/github/GithubObject.py", line 268, in __complete
    self._url.value
  File "/home/user/.local/lib/python3.6/site-packages/github/Requester.py", line 262, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
  File "/home/user/.local/lib/python3.6/site-packages/github/Requester.py", line 278, in __customConnection
    if not url.startswith("/"):
AttributeError: 'NoneType' object has no attribute 'startswith'

Below is an example of the code:

from github import Github

g = Github(per_page=300)
i = 1
for repo in g.search_topics('security'):
    print(i, repo.archive_url)
    i += 1

It can be tested here: https://repl.it/repls/LawngreenPlushBetaversion

Environment:
Linux ubuntu 4.15.0-36-generic x86_64 GNU/Linux
Python 3.6.6
PyGithub 1.43.2

Any help with that ?
And thanks

@qiaohao9
Copy link

I will fix it later :p

@qiaohao9
Copy link

qiaohao9 commented Oct 14, 2018

Maybe, wrong code is here. @jacquerie

@jacquerie
Copy link
Contributor

Maybe, wrong code is here. @jacquerie

Uhm? I don't think I contributed code to any of this...

@schreck61
Copy link

Just glancing at the code. It appears that search_topics is returning a paginated list of GitHub repositories, but the API seems to return a list of topics, including the following properties:

  • name
  • display_name
  • short_description
  • description
  • created_by
  • released
  • created_at
  • updated_at
  • featured
  • curated
  • score

I think this may be the root problem.

@men1n2
Copy link
Author

men1n2 commented Oct 31, 2018

Yes indeed, the API endpoint /search/topics returns a list of topics that are related to the provided keyword and not a list of repositories tagged with that topic (which is a little bit confusing, maybe ?).
In my code I used the other API endpoints and it worked fine.

But still, the method in PyGithub should be fixed.

@sfdye
Copy link
Member

sfdye commented Oct 31, 2018

PR welcome

s-t-e-v-e-n-k added a commit to s-t-e-v-e-n-k/PyGithub that referenced this issue Nov 12, 2018
The return value of MainClass.search_topics() was a paginated list of
Repository, which is incorrect. Add a Topic class to encapuslate what is
returned.

Fixes PyGithub#929
sfdye pushed a commit that referenced this issue Nov 13, 2018
The return value of MainClass.search_topics() was a paginated list of
Repository, which is incorrect. Add a Topic class to encapuslate what is
returned.

Fixes #929
candrikos pushed a commit to candrikos/PyGithub that referenced this issue Sep 25, 2020
The return value of MainClass.search_topics() was a paginated list of
Repository, which is incorrect. Add a Topic class to encapuslate what is
returned.

Fixes PyGithub#929
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants