CNDRD / siegeapi

Rainbow Six Siege Python API Interface
https://cndrd.github.io/siegeapi/
MIT License
56 stars 5 forks source link

Exception when trying to run the example code #9

Closed mrticker closed 2 years ago

mrticker commented 2 years ago

When running the example code (Windows, Python 3.8.12), I get an exception. Here's the final part of it:

C:\usr\Miniconda3\lib\site-packages\siegeapi\player.py in <module>
      6 from .url_builder import UrlBuilder
      7 from .operators import Operators
----> 8 from .weapons import Weapons
      9 from .trends import Trends
     10 from .ranks import Rank

C:\usr\Miniconda3\lib\site-packages\siegeapi\weapons.py in <module>
     29
     30
---> 31 class WeaponsGameMode:
     32     def __init__(self, data: dict):
     33         self.primary: list = self._get_weapons_list(data.get("weaponSlots", {}).get("primary
Weapons", {}).get("weaponTypes", [{}])[0].get("weapons", []))

C:\usr\Miniconda3\lib\site-packages\siegeapi\weapons.py in WeaponsGameMode()
     35
     36     @staticmethod
---> 37     def _get_weapons_list(data: List[dict] | None) -> List[Weapon] | None:
     38         return None if not data else [Weapon(weapon) for weapon in data]
     39

TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'NoneType'

Any thoughts?

CNDRD commented 2 years ago

Whoops, sorry, my bad.. This is caused by improper type annotations in _get_weapons_list I am running the latest Python 3.10 and sometimes I forget to check if the typings are corrrect for older versions ~I'll release a fixed version shortly~ Fixed 😃

CNDRD commented 2 years ago

New version is up 😃 GitHub PyPI