e4c6 / eksi_unofficial_api

Ekşisözlük.com Unofficial API docs & client
MIT License
35 stars 7 forks source link

AssertionError for get_user_entries() when the user has a pinned entry #14

Closed ghost closed 2 years ago

ghost commented 2 years ago
>>> from eksisozluk.EksiSozluk import EksiApi
>>> client = EksiApi()
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.eksisozluk.com:443
DEBUG:urllib3.connectionpool:https://api.eksisozluk.com:443 "POST /v2/account/anonymoustoken HTTP/1.1" 200 None
DEBUG:eksisozluk.EksiSozluk:Token: EksiToken(rank=0, access_token='31hv4Vt0Jp9otf1OybxHQgHvmWSnPhfJKrJlyCxV1O87JO6GNb6nFDAE7fTFueLsGAUbQ5v3DuMVNd27-gDABWK1eP07FjCJXOvQfStDnDzjXccHYExzEYIn_Ko4p3fvySeztvXTZDlf1Z9IfuS9JRzD_WjX4McaT1Up81MGHXUo7sQZuKG7u7DcNgJr0okImkbwhHGhsZT6DreGvc3VdA', token_type='bearer', expires_in=86400, user_id=None, refresh_token=None, nick=None, issued_at=datetime.datetime(2021, 11, 29, 11, 44, 16, 934765), expires_at=datetime.datetime(2021, 11, 30, 11, 44, 16, 934765))
>>> client.get_user_entries("ssg")
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.eksisozluk.com:443
DEBUG:urllib3.connectionpool:https://api.eksisozluk.com:443 "GET /v2/user/ssg/entries?p=1 HTTP/1.1" 200 None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/x/.virtualenvs/eksisozluk/lib/python3.9/site-packages/eksisozluk/EksiSozluk.py", line 166, in get_user_entries
    return UserEntriesResponse.from_dict(response.json())
  File "/home/x/.virtualenvs/eksisozluk/lib/python3.9/site-packages/eksisozluk/Models/Responses/UserEntriesResponse.py", line 45, in from_dict
    data = UserEntries.from_dict(obj.get("Data"))
  File "/home/x/.virtualenvs/eksisozluk/lib/python3.9/site-packages/eksisozluk/Models/Responses/UserEntriesResponse.py", line 17, in from_dict
    pinned_entry = from_none(obj.get("PinnedEntry"))
  File "/home/x/.virtualenvs/eksisozluk/lib/python3.9/site-packages/eksisozluk/Models/__init__.py", line 15, in from_none
    assert x is None
AssertionError

I'm not sure how to solve it because I don't really understand the exact purpose of from_none().

e4c6 commented 2 years ago

I created models using sample responses so some attributes were null, we'll eventually get to address all of these. @cagriozkurt