Skip to content

Commit

Permalink
trying to satisfy linters
Browse files Browse the repository at this point in the history
  • Loading branch information
Liberatorist committed Sep 21, 2024
1 parent 3b251cd commit ed95df3
Show file tree
Hide file tree
Showing 6 changed files with 1,808 additions and 1,561 deletions.
27 changes: 13 additions & 14 deletions poe_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from yarl import URL

from poe_client.rate_limiter import RateLimiter
from poe_client.schemas import league
from poe_client.schemas.account import Account, Realm
from poe_client.schemas.character import Character
from poe_client.schemas.filter import ItemFilter
Expand Down Expand Up @@ -65,6 +64,18 @@ async def __aexit__(
raise exc_val
return True

def can_make_request(
self,
path: str,
path_format_args: Optional[List[str]] = None,
) -> bool:
"""Check if a request can be made to the given path without having to wait."""
if not path_format_args:
path_format_args = []
path_with_no_args = path.format(("" for _ in range(len(path_format_args))))
policy_name = self._path_to_policy_names.get(path_with_no_args, "")
return self._limiter.is_restricted(policy_name)

# Type ignore is for args and kwargs, which have unknown types we pass to _get_json
async def _get( # type: ignore
self,
Expand Down Expand Up @@ -182,7 +193,7 @@ async def _get_json(
# positional argument in the function.
async with await self._client.get(
"{0}/{1}".format(self._base_url, path.format(*path_format_args)),
**kwargs, # type: ignore
**kwargs,
) as resp:
self._path_to_policy_names[
path_with_no_args
Expand All @@ -197,17 +208,6 @@ async def _get_json(

return await resp.json()

def can_make_request(
self,
path: str,
path_format_args: Optional[List[str]] = None,
) -> bool:
if not path_format_args:
path_format_args = []
path_with_no_args = path.format(("" for _ in range(len(path_format_args))))
policy_name = self._path_to_policy_names.get(path_with_no_args, "")
return self._limiter.is_restricted(policy_name)


class _PvPMixin(Client):
"""PVP related methods for the POE API.
Expand Down Expand Up @@ -500,7 +500,6 @@ async def get_leage_account(
Args:
league: str
"""

return await self._get(
path="league-account/{0}",
path_format_args=(league,),
Expand Down
2 changes: 1 addition & 1 deletion poe_client/rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RateLimiter(object):
policies: Dict[str, Dict[str, Policy]]
mutex: asyncio.Lock

def __init__(self):
def __init__(self) -> None:
"""Initialize a new RateLimiter."""
self.policies = {}
self.mutex = asyncio.Lock()
Expand Down
4 changes: 2 additions & 2 deletions poe_client/schemas/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ class Ladder(Model):


class AtlasPassiveHashes(Model):
"""Datacass to describe the Atlas Passive field of a LeagueAccount"""
"""Datacass to describe the Atlas Passive field of a LeagueAccount."""

hashes: List[int]


class LeagueAccount(Model):
"""Dataclass to describe a LeagueAccount"""
"""Dataclass to describe a LeagueAccount."""

atlas_passives: Optional[AtlasPassiveHashes]
Loading

0 comments on commit ed95df3

Please sign in to comment.