paperswithcode / paperswithcode-client

API Client for paperswithcode.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

paper_repository_list() fails with `TypeError: ModelMetaclass object argument after ** must be a mapping, not str`

sergicastellasape opened this issue · comments

I've noticed that calling the method paper_repository_list() (and other methods with that follow the same structure). From what I've come to conclude, the problem is that in the return line return [Repository(**r) for r in self.http.get(f"/papers/{paper_id}/repositories/") ], the HTTP request returns a dict such as:

 'next': None,
 'previous': None,
 'results': [{'url': 'https://github.com/andreev-io/Simulated-Annealing',
   'is_official': False,
   'description': 'Implementation of the 1983 Simulated Annealing paper (Kirkpatrick et al.) in Rust. Combinatorial optimization, traveling salesman.',
   'stars': 1,
   'framework': 'none'}]}

so looping with that only gives the keys of this dict, instead of the list of results. I believe that adding the key 'results' should fix the problem, as the list comprehension would be looping indeed with each list element (a dict):
return [Repository(**r) for r in self.http.get(f"/papers/{paper_id}/repositories/")["results"]]

Fixed. Will be released tomorrow in a 0.2.0 version of the client.