Skip to content

Commit

Permalink
QA Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
calendulish committed Aug 30, 2024
1 parent b33e544 commit 3510f39
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/stlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@

try:
from stlib import steamworks # type: ignore
except ImportError:
except ImportError as exception:
raise NoSteamWorksError(
'stlib has been built without SteamWorks support. '
'Client interface is unavailable'
)
) from exception

log = logging.getLogger(__name__)

Expand Down
12 changes: 6 additions & 6 deletions src/stlib/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ async def get_inventory(
:return: List of `Item`
"""
params = {'l': 'english', 'count': count}
json_data = {}
json_data: Dict[str, Any] = {}

while True:
json_data |= await self.request_json(
Expand Down Expand Up @@ -560,7 +560,7 @@ async def get_my_orders(self) -> Tuple[List[Order], List[Order]]:
:return: sell orders (`Order`) and buy orders (`Order`)
"""
params = {"start": 0, "count": 100, "norender": 1, "l": "english"}
json_data = {}
json_data: Dict[str, Any] = {}

while True:
json_data |= await self.request_json(
Expand Down Expand Up @@ -640,8 +640,8 @@ async def get_item_histogram(self, appid: int, hash_name: str) -> Histogram:
start = item_activity_func.index("LoadOrderSpread") + 17
end = item_activity_func[start:].index(" );") + start
item_nameid = item_activity_func[start:end]
except ValueError:
raise MarketError("Unable to load market orders")
except ValueError as exception:
raise MarketError("Unable to load market orders") from exception

wallet_vars = self.get_vars_from_js(scripts[-2])

Expand All @@ -664,8 +664,8 @@ async def get_item_histogram(self, appid: int, hash_name: str) -> Histogram:
f"{self.community_url}/market/itemordershistogram", params=params
)

sell_order_table = []
buy_order_table = []
sell_order_table: List[PriceInfo] = []
buy_order_table: List[PriceInfo] = []

if 'sell_order_table' in json_data and json_data['sell_order_table']:
sell_order_table.extend(
Expand Down
5 changes: 1 addition & 4 deletions src/stlib/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,4 @@ async def is_limited(self) -> bool:
html = await self.request_html('https://steamcommunity.com/dev/apikey')
main = html.find('div', id='mainContents')

if 'Access Denied' in main.find('h2').text:
return True

return False
return 'Access Denied' in main.find('h2').text
4 changes: 2 additions & 2 deletions src/stlib/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, custom_search_paths: Tuple[str, ...] = ()) -> None:
try:
plugin_spec.loader.exec_module(module_) # type: ignore
except ImportError as exception:
raise PluginLoaderError(exception)
raise PluginLoaderError(exception) from exception

log.debug("Plugin %s loaded.", module_name)
self._plugins[module_.__name__] = module_
Expand Down Expand Up @@ -147,7 +147,7 @@ def get_available_plugins() -> List[str]:
Return a list of available plugins
:return: list of available plugins
"""
return list(manager.plugins.keys())
return list(manager.plugins.keys()) # noqa


@_plugin_manager
Expand Down
4 changes: 2 additions & 2 deletions src/stlib/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __add__(self, value: int | float) -> 'SteamPrice':
def __sub__(self, value: int | float) -> 'SteamPrice':
return SteamPrice(round(self._price - value, 2))

def __lt__(self, other: Self) -> bool:
def __lt__(self, other: object) -> bool:
if isinstance(other, int):
return round(self._price * 100) < other
elif isinstance(other, float):
Expand All @@ -120,7 +120,7 @@ def __lt__(self, other: Self) -> bool:
else:
raise NotImplementedError(f"Comparation with {type(other)} not implemented")

def __eq__(self, other: Self) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, int):
return round(self._price * 100) == other
elif isinstance(other, float):
Expand Down
3 changes: 1 addition & 2 deletions src/stlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
"""

import asyncio
import atexit
import contextlib
import http.cookies
import json
import locale
import logging
from typing import Dict, Any, NamedTuple, Self

import aiohttp
import atexit
from bs4 import BeautifulSoup

log = logging.getLogger(__name__)
Expand Down

0 comments on commit 3510f39

Please sign in to comment.