Skip to content

Commit

Permalink
update deps, ruff lint/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
falkben committed Oct 18, 2024
1 parent 0e563c7 commit 39fdc81
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 37 deletions.
16 changes: 8 additions & 8 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ alembic==1.13.3
# steam2sqlite (pyproject.toml)
aniso8601==9.0.1
# via graphene
anyio==4.6.0
anyio==4.6.2.post1
# via
# -c requirements.txt
# httpx
Expand All @@ -28,7 +28,7 @@ certifi==2024.8.30
# httpcore
# httpx
# requests
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via
# -c requirements.txt
# requests
Expand All @@ -44,7 +44,7 @@ click-default-group==1.2.4
# -c requirements.txt
# datasette
# sqlite-utils
coverage==7.6.1
coverage==7.6.3
# via pytest-cov
datasette==0.65
# via
Expand Down Expand Up @@ -75,7 +75,7 @@ flexparser==0.3.1
# datasette
graphene==3.3
# via datasette-graphql
graphql-core==3.2.4
graphql-core==3.2.5
# via
# datasette-graphql
# graphene
Expand Down Expand Up @@ -194,9 +194,9 @@ requests==2.32.3
# via
# -c requirements.txt
# dropbox
ruff==0.6.9
ruff==0.7.0
# via steam2sqlite (pyproject.toml)
setuptools==75.1.0
setuptools==75.2.0
# via
# -c requirements.txt
# datasette
Expand Down Expand Up @@ -249,11 +249,11 @@ urllib3==2.2.3
# via
# -c requirements.txt
# requests
uvicorn==0.31.0
uvicorn==0.32.0
# via
# -c requirements.txt
# datasette
uvloop==0.20.0
uvloop==0.21.0
# via
# -c requirements.txt
# steam2sqlite (pyproject.toml)
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ aiofiles==24.1.0
# via datasette
alembic==1.13.3
# via steam2sqlite (pyproject.toml)
anyio==4.6.0
anyio==4.6.2.post1
# via httpx
asgi-csrf==0.10
# via datasette
Expand All @@ -15,7 +15,7 @@ certifi==2024.8.30
# httpcore
# httpx
# requests
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via requests
click==8.1.7
# via
Expand Down Expand Up @@ -93,7 +93,7 @@ pyyaml==6.0.2
# via datasette
requests==2.32.3
# via dropbox
setuptools==75.1.0
setuptools==75.2.0
# via datasette
six==1.16.0
# via
Expand Down Expand Up @@ -125,7 +125,7 @@ typing-extensions==4.12.2
# sqlalchemy2-stubs
urllib3==2.2.3
# via requests
uvicorn==0.31.0
uvicorn==0.32.0
# via datasette
uvloop==0.20.0
uvloop==0.21.0
# via steam2sqlite (pyproject.toml)
2 changes: 1 addition & 1 deletion scripts/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main(argv: Sequence[str] | None = None) -> int:
parser.add_argument(
"--token",
default=TOKEN,
help="Access token " "(see https://www.dropbox.com/developers/apps)",
help="Access token (see https://www.dropbox.com/developers/apps)",
)
args = parser.parse_args(argv)

Expand Down
17 changes: 7 additions & 10 deletions steam2sqlite/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ def get_or_create(session, model, **kwargs):
instance = session.query(model).filter_by(**kwargs).first()
if instance:
return instance
else:
instance = model(**kwargs)
session.add(instance)
session.flush()
return instance
instance = model(**kwargs)
session.add(instance)
session.flush()
return instance


def update_or_create(session, model, filterargs, **kwargs):
Expand Down Expand Up @@ -152,7 +151,7 @@ def load_app_into_db(session: Session, data: dict) -> SteamApp:
if release_date_str:
release_date = datetime.strptime(release_date_str, "%b %d, %Y").date()
except ValueError:
# todo: log this error
# TODO: log this error
pass

initial_price = current_price = None
Expand Down Expand Up @@ -224,9 +223,7 @@ def get_error_appids(session: Session) -> list[int]:
def record_appid_error(
session, appid: int, name: str | None = None, reason: str | None = None
):
get_or_create(
session, AppidError, **{"appid": appid, "name": name, "reason": reason}
)
get_or_create(session, AppidError, appid=appid, name=name, reason=reason)
session.commit()


Expand All @@ -239,7 +236,7 @@ def get_apps_data(
responses = asyncio.run(navigator.make_requests(urls))

apps_data = []
for appid, resp in zip(appids, responses):
for appid, resp in zip(appids, responses, strict=False):
# make_requests inserts exceptions into the responses list
if isinstance(resp, navigator.NavigatorError):
logger.error(f"Error getting app data for {appid}")
Expand Down
1 change: 0 additions & 1 deletion steam2sqlite/navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ async def get(

async def make_requests(urls: list[str]) -> list[httpx.Response]:
"""List of urls to a list of responses using asyncio"""

limits = httpx.Limits(max_connections=10, max_keepalive_connections=5)
async with httpx.AsyncClient(
headers={"accept": "application/json"}, timeout=10, limits=limits
Expand Down
2 changes: 1 addition & 1 deletion steam2sqlite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def grouper(iterable, n, fillvalue=None):
"Collect data into non-overlapping fixed-length chunks or blocks"
"""Collect data into non-overlapping fixed-length chunks or blocks"""
# https://docs.python.org/3/library/itertools.html#itertools-recipes
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx
args = [iter(iterable)] * n
Expand Down
15 changes: 5 additions & 10 deletions tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def session():

def get_apps_data(appids: list[str]):
"""'mocks' the handler.get_apps_data function"""

# todo: actually mock the handler function replacing the url requests w/ static data
# TODO: actually mock the handler function replacing the url requests w/ static data

apps_data = []
for appid in appids:
Expand All @@ -33,8 +32,7 @@ def get_apps_achievements(
apps: list[models.SteamApp],
) -> list[tuple[models.SteamApp, list[dict]]]:
"""'mocks' handler.get_apps_achievements function"""

# todo: actually mock the handler function replacing the url requests w/ static data
# TODO: actually mock the handler function replacing the url requests w/ static data

apps_achievements_data = []
for app in apps:
Expand All @@ -60,11 +58,10 @@ def portal_achievements(session, portal_app):


def test_app_with_duplicated_appid(session):
"""portal 2 is listed more than once with different appids (620, 659)
"""Portal 2 is listed more than once with different appids (620, 659)
However the preorder (659) has an internal appid of 620
We want to assert that we don't ingest dup items
"""

dup_appid = "659"
dup_app_data = get_apps_data([dup_appid])[0]

Expand Down Expand Up @@ -114,8 +111,7 @@ def test_ingest_item_twice(session: Session):


def test_updates_on_diff_app_data(session: Session, portal_app: models.SteamApp):
"""assert updates on new app data"""

"""Assert updates on new app data"""
appid = "620"
app_data = get_apps_data([appid])[0]

Expand All @@ -131,7 +127,7 @@ def test_updates_on_diff_app_data(session: Session, portal_app: models.SteamApp)
def test_updates_on_diff_achievement_data(
session: Session, portal_app: models.SteamApp, portal_achievements
):
"""assert updates on diff achievement data"""
"""Assert updates on diff achievement data"""
apps_achievements_data = get_apps_achievements([portal_app])
portal_achievements_data = apps_achievements_data[0]
modified_achievement_name = portal_achievements_data[1][0]["name"]
Expand All @@ -156,7 +152,6 @@ def test_duplicate_achievements_on_app(
"""App with duplicated achievements
assert clear out achievements with updates
"""

# duplicate the first achievement
first_achievement = portal_app.achievements[0]
a = models.Achievement(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


def test_main():
"""runs the script for a brief time"""
"""Runs the script for a brief time"""
result = main.main(("--limit", "0.1"))
assert result == 0
1 change: 1 addition & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time

import pytest

from steam2sqlite import utils


Expand Down

0 comments on commit 39fdc81

Please sign in to comment.