Fix type errors

This commit is contained in:
Correl Roush 2024-02-21 17:38:20 -05:00
parent 61544ed521
commit 04ad554d3c
4 changed files with 323 additions and 366 deletions

673
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@ authors = ["Correl Roush <correl@gmail.com>"]
[tool.poetry.dependencies]
python = "^3.9"
tornado = "^6.1"
click = "^8.0.1"
click = "^8.1.7"
humanize = "^3.10.0"
httpx = "^0.18.2"
parsy = "^1.3.0"

View file

@ -26,7 +26,8 @@ async def load(
- MTGStand (uses Scryfall ID)
"""
async with await psycopg.AsyncConnection.connect(
settings["database"], autocommit=False
settings["database"],
autocommit=False,
) as conn:
async with conn.cursor() as cursor:
if mode == ImportMode.replace:
@ -36,7 +37,9 @@ async def load(
is_foil = "Foil" in row and row["Foil"].lower() == "foil"
quantity = int(row.get("Quantity", row.get("Count", 1)))
if "Creation Date" in row:
created_date = arrow.get(row["Creation Date"].replace('_', ' '))
created_date = arrow.get(
row["Creation Date"].replace("_", " ")
).datetime
else:
created_date = datetime.datetime.now()
if "Scryfall ID" in row:

View file

@ -302,6 +302,9 @@ class DecksHandler(OpenAPIRequestHandler, RequestHandler):
async with self.pool.connection() as conn:
async with conn.cursor() as cursor:
deck_id = await tutor.database.store_deck(cursor, name)
if not deck_id:
logger.error("Failed to store new deck")
raise tornado.web.HTTPError(500)
deck = tutor.models.Deck(deck_id, name, [])
self.write(json.dumps(deck, cls=JSONEncoder))
@ -310,7 +313,7 @@ class DecksHandler(OpenAPIRequestHandler, RequestHandler):
class DeckHandler(RequestHandler):
async def prepare(self) -> None:
self.connection = await self.pool.getconn()
self.deck_id = self.path_args[0]
self.deck_id = int(self.path_args[0])
content_type = self.request.headers.get("Content-Type", "text/plain")
if content_type == "text/plain":
self.importer = DeckImporter()