cassiopeia
cassiopeia copied to clipboard
Fix crash when loading accounts
This would previously fail with the following error:
File ".../cassiopeia/datastores/riotapi/account.py", line 89, in get_account
data["region"] = query["platform"].region.value
~~~~^^^^^^^^^^
TypeError: 'str' object does not support item assignment
@jjmaldonis
+1 to getting the error
Name: Pobelter
Making call: https://americas.api.riotgames.com/riot/account/v1/accounts/by-riot-id/Pobelter/NA1
Traceback (most recent call last):
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/merakicommons/ghost.py", line 41, in wrapper
return method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/cassiopeia/core/account.py", line 154, in puuid
return self._data[AccountData].puuid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AccountData' object has no attribute 'puuid'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/merakicommons/ghost.py", line 87, in __get__
return self.fget(obj)
^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/merakicommons/ghost.py", line 43, in wrapper
raise GhostLoadingRequiredError(str(error))
merakicommons.ghost.GhostLoadingRequiredError: 'AccountData' object has no attribute 'puuid'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/datapipelines/sources.py", line 69, in wrapper
return call(self, query, context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/datapipelines/queries.py", line 326, in wrapped
return method(self, query, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/cassiopeia/datastores/riotapi/account.py", line 89, in get_account
data["region"] = query["platform"].region.value
~~~~^^^^^^^^^^
TypeError: 'str' object does not support item assignment
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/stephen/Github/cassiopeia/examples/leagues.py", line 46, in <module>
print_leagues("Pobelter", "NA1", "NA")
File "/Users/stephen/Github/cassiopeia/examples/leagues.py", line 9, in print_leagues
print("ID:", account.summoner.id)
^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/cassiopeia/core/account.py", line 176, in summoner
return Summoner(puuid=self.puuid, region=self.region)
^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/merakicommons/ghost.py", line 90, in __get__
obj.__load__(load_group)
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/cassiopeia/core/common.py", line 272, in __load__
data = configuration.settings.pipeline.get(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/datapipelines/pipelines.py", line 459, in get
return handler.get(query, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/datapipelines/pipelines.py", line 185, in get
result = self._source.get(self._source_type, deepcopy(query), context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/datapipelines/sources.py", line 120, in get
return source.get(type, deepcopy(query), context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/stephen/.pyenv/versions/3.12.5/lib/python3.12/site-packages/datapipelines/sources.py", line 71, in wrapper
raise DataSource.unsupported(type)
datapipelines.common.UnsupportedError: The type "AccountDto" is not supported by this DataSource!```