nxtlo / aiobungie

Python and asyncio Bungie API wrapper.
https://nxtlo.github.io/aiobungie/
MIT License
52 stars 10 forks source link

GREEN_PIPS = 10 missing from ValueUIStyle enumerator #131

Closed GregShiner closed 2 years ago

GregShiner commented 2 years ago

Long story short.

The enumeration for GreenPips is not in the ValueUIStyle enumerator.

Expected Result

The value 10 would be enumerated to GREEN_PIPS

Actual Result

This bug causes a ValueError when you try to enumerate 10.

  File "/home/gman1230321/bountyoptimizer/Bounty-Optimization-Tool/app.py", line 53, in getCharacters
    objectives = [await objective.fetch_self() for objective in objectives]
  File "/home/gman1230321/bountyoptimizer/Bounty-Optimization-Tool/app.py", line 53, in <listcomp>
    objectives = [await objective.fetch_self() for objective in objectives]
  File "/home/gman1230321/bountyoptimizer/Bounty-Optimization-Tool/lib/python3.9/site-packages/aiobungie/crate/records.py", line 111, in fetch_self
    return await self.net.request.fetch_objective_entity(self.hash)
  File "/home/gman1230321/bountyoptimizer/Bounty-Optimization-Tool/lib/python3.9/site-packages/aiobungie/client.py", line 939, in fetch_objective_entity
    return self.factory.deserialize_objective_entity(resp)
  File "/home/gman1230321/bountyoptimizer/Bounty-Optimization-Tool/lib/python3.9/site-packages/aiobungie/internal/factory.py", line 1702, in deserialize_objective_entity
    progress_value_style=entity.ValueUIStyle(payload["inProgressValueStyle"]),
  File "/usr/lib/python3.9/enum.py", line 360, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.9/enum.py", line 678, in __new__
    raise ve_exc
ValueError: 10 is not a valid ValueUIStyle

System info

Ubuntu 20.04 on WSL Python 3.9.5 aiobungie 0.2.5

Further info

The solution is incredibly simple. Just add GREEN_PIPS = 10 to class ValueUIStyle(enums.IntEnum): in crate.entity.py. I've attached a patch file that will solve this issue. I'm having trouble right now getting a development copy on my system so I can't just submit a PR at this moment. Just apply the patch to crate/entity.py with patch crate/entity.py < patch.txt patch.txt

GregShiner commented 2 years ago

Additionally, here is the Bungie.net API documentation for this enumerator for reference. https://bungie-net.github.io/#/components/schemas/Destiny.DestinyUnlockValueUIStyle

GregShiner commented 2 years ago

I made a PR just using the GitHub built-in editor but I have not been able to run tests since I cannot get my environment to work properly.

nxtlo commented 2 years ago

Thanks for catching that, Will take a look at the PR now :)