Renondedju / Osu.py

A simple python implementation for the Osu! api
MIT License
5 stars 4 forks source link

Error when getting user #8

Closed RealMoondancer closed 2 years ago

RealMoondancer commented 2 years ago

Describe the bug An error is raised when trying to get the user using Python 3.10

Error report

Traceback (most recent call last):
  File "C:\Users\Admin\.virtualenvs\twitchbot-ckDLcYWF\lib\site-packages\twitchio\client.py", line 193, in wrapped
    await func(*args)
  File "C:\Users\Admin\Documents\twitchbot\bot.py", line 19, in event_ready
    self.too_md = await self.api.get_user("too_md")
  File "C:\Users\Admin\.virtualenvs\twitchbot-ckDLcYWF\lib\site-packages\pyosu\api.py", line 168, in get_user
    return User(user_events=[UserEvent(**event) for event in data.get('events', [])], **data, api=self)
  File "C:\Users\Admin\.virtualenvs\twitchbot-ckDLcYWF\lib\site-packages\pyosu\api.py", line 168, in <listcomp>
    return User(user_events=[UserEvent(**event) for event in data.get('events', [])], **data, api=self)
  File "C:\Users\Admin\.virtualenvs\twitchbot-ckDLcYWF\lib\site-packages\pyosu\models\user_event.py", line 35, in __init__
    self.beatmap_id     = int(data.get('beatmap_id'   , 0 ))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

To Reproduce Steps to reproduce the behavior:

  1. Create OsuApi in Python 3.10
  2. Await api.get_user("some user")

Expected behavior The Api would return the User Struct

Python version Python 3.10.1

Renondedju commented 2 years ago

I cannot reproduce the bug and need further information.

RealMoondancer commented 2 years ago
Renondedju commented 2 years ago

Just released v0.5.3, this should fix the issue.
The Osu API seems to be sending null values instead of omitting them all together (as it previously did?)

Anyway, make sure to update the lib by running pip install -U git+https://github.com/Renondedju/Osu.py on the right python installation. I'm waiting for your validation to close the issue.

RealMoondancer commented 2 years ago

Works now, thanks for the fix