paperswithcode / paperswithcode-client

API Client for paperswithcode.com
Apache License 2.0
152 stars 21 forks source link

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

Closed sergicastellasape closed 3 years ago

sergicastellasape commented 3 years ago

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"]]

alefnula commented 3 years ago

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