Skip to content

Commit

Permalink
chore(linter): updating exsiting files
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardodalinky committed Sep 26, 2023
1 parent eeff8e5 commit ebf82cd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 45 deletions.
5 changes: 1 addition & 4 deletions examples/worldstate/custom_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
from typing import Literal

from warframe.worldstate import WorldstateClient
from warframe.worldstate.common.core import ( # this import might change
SingleQueryModel,
TimedEvent,
)
from warframe.worldstate.common.core import SingleQueryModel, TimedEvent # this import might change


class CustomCambionDrift(SingleQueryModel, TimedEvent):
Expand Down
8 changes: 2 additions & 6 deletions examples/worldstate/listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ async def on_cetus_state_change(cetus: Cetus):


async def main():
print(
(await client.query(OrbVallis))
) # this is just to have a reference to the current state
print(
(await client.query(Cetus))
) # this is just to have a reference to the current state
print((await client.query(OrbVallis))) # this is just to have a reference to the current state
print((await client.query(Cetus))) # this is just to have a reference to the current state
on_vallis_state_change.start() # start the listener
on_cetus_state_change.start()
await asyncio.sleep(3600) # for testing, we wait an hour here
Expand Down
8 changes: 6 additions & 2 deletions examples/worldstate/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
async def main():
async with WorldstateClient() as client:
# import from models and pass the type you want the object of
arbi = await client.query(Arbitration) # of Type SingleQuery - a single object of type `Arbitration`
fissures = await client.query(Fissure) # of Type MultiQuery - a list of objects of type `Fissure`
arbi = await client.query(
Arbitration
) # of Type SingleQuery - a single object of type `Arbitration`
fissures = await client.query(
Fissure
) # of Type MultiQuery - a list of objects of type `Fissure`

print(arbi)
for fissure in fissures:
Expand Down
40 changes: 8 additions & 32 deletions warframe/worldstate/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
import logging
from datetime import datetime, timezone
from functools import wraps
from typing import (
Any,
Callable,
Coroutine,
List,
Optional,
Type,
TypeVar,
Union,
overload,
)
from typing import Any, Callable, Coroutine, List, Optional, Type, TypeVar, Union, overload

import aiohttp
import msgspec
Expand Down Expand Up @@ -113,21 +103,15 @@ async def _request(

url = build_endpoint(type, language)

logging.getLogger(__name__).debug(
f"Sending request to the {type.__name__} endpoint"
)
logging.getLogger(__name__).debug(f"Sending request to the {type.__name__} endpoint")

async with self._session.get(url) as response:
response_text = await response.text()

if response.status != 200:
raise WorldstateAPIError(
msgspec.json.decode(response_text, type=ErrorMessage)
)
raise WorldstateAPIError(msgspec.json.decode(response_text, type=ErrorMessage))

logging.getLogger(__name__).debug(
f"Got request from the {type.__name__} endpoint"
)
logging.getLogger(__name__).debug(f"Got request from the {type.__name__} endpoint")

return response_text

Expand Down Expand Up @@ -227,19 +211,15 @@ async def get_cetus(self, language: Optional[Language] = None) -> Cetus:
json = await self._request(Cetus, language)
return Cetus._from_json(json)

async def get_cambion_drift(
self, language: Optional[Language] = None
) -> CambionDrift:
async def get_cambion_drift(self, language: Optional[Language] = None) -> CambionDrift:
json = await self._request(CambionDrift, language)
return CambionDrift._from_json(json)

async def get_orb_vallis(self, language: Optional[Language] = None) -> OrbVallis:
json = await self._request(OrbVallis, language)
return OrbVallis._from_json(json)

async def get_alerts(
self, language: Optional[Language] = None
) -> Optional[List[Alert]]:
async def get_alerts(self, language: Optional[Language] = None) -> Optional[List[Alert]]:
json = await self._request(OrbVallis, language)
return Alert._from_json(json)

Expand Down Expand Up @@ -273,12 +253,8 @@ def listen_to(self, type: Type[SingleQueryTimedEvent]):
Returns:
_TaskHelper: A helper class that wraps the callback function. Call `.start()` on it in order to start the listener. Same goes for `.stop()`
"""
if not issubclass(type, SingleQueryModel) and not not issubclass(
type, TimedEvent
):
raise TypeError(
f"{type.__name__} has to implement SingleQueryModel and TimedEvent"
)
if not issubclass(type, SingleQueryModel) and not not issubclass(type, TimedEvent):
raise TypeError(f"{type.__name__} has to implement SingleQueryModel and TimedEvent")

def decorator(
func: Callable[[SingleQueryTimedEvent], Coroutine[Any, Any, None]]
Expand Down
2 changes: 1 addition & 1 deletion warframe/worldstate/enums/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .faction import *
from .mission_type import *
from .language import *
from .mission_type import *
from .syndicate import Syndicate

0 comments on commit ebf82cd

Please sign in to comment.