diff --git a/.github/workflows/alembic.yml b/.github/workflows/alembic.yml index a2478cb..860422c 100644 --- a/.github/workflows/alembic.yml +++ b/.github/workflows/alembic.yml @@ -21,7 +21,9 @@ jobs: POSTGRES_HOST_AUTH_METHOD: trust steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 + with: + fetch-depth: 1 - name: Wait for PostgreSQL to be ready run: | @@ -32,7 +34,6 @@ jobs: - name: Install dependencies run: | - # for python3.11 (dear internet gods: we'll update to 3.13 or something in a year, i promise) sudo add-apt-repository ppa:deadsnakes/ppa sudo apt install python3.13 python3.13-venv python3.13 -m pip install --upgrade pip diff --git a/.github/workflows/pytest_unit.yml b/.github/workflows/pytest_unit.yml index 5582723..41dc376 100644 --- a/.github/workflows/pytest_unit.yml +++ b/.github/workflows/pytest_unit.yml @@ -7,13 +7,13 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v6 with: python-version: '3.13' - - uses: actions/cache@v4 + - uses: actions/cache@v5 id: cache with: path: ~/.cache/pip diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 9c57160..b213240 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -4,7 +4,5 @@ jobs: ruff: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 - with: - version: 0.15.12 + - uses: actions/checkout@v6 + - uses: astral-sh/ruff-action@v3 diff --git a/README.md b/README.md index f8e3637..f8a5c73 100755 --- a/README.md +++ b/README.md @@ -14,8 +14,7 @@ If you're planning to read through the source code, please check out this projec ### Quickstart -1. Install [Python 3.11](https://www.python.org/downloads/), [git](https://git-scm.com/install/), and (optionally) [Docker](https://www.docker.com/get-started/) - Note: This may fail if you're using Python 3.12+ +1. Install [Python 3.13](https://www.python.org/downloads/), [git](https://git-scm.com/install/), and (optionally) [Docker](https://www.docker.com/get-started/) 2. Clone this repository 3. Create and activate a virtual environment for this project. This has been tested with `pip` and `uv` 4. Install developer dependencies @@ -57,5 +56,5 @@ export LOCAL=true # Should be true if you're running this locally ## Developer Tools -We use `ruff 0.6.9` as our linter, which you can run with `ruff check --fix`. If you use a different version, it may be inconsistent with our CI checks. +We use `ruff` as our linter, which you can run with `ruff check --fix`. If you use a different version, it may be inconsistent with our CI checks. We use `pyright/basedpyright` for typechecking. Language services have been left enabled and will be changed if it becomes an issue. diff --git a/src/auth/urls.py b/src/auth/urls.py index 8516769..635f2c6 100644 --- a/src/auth/urls.py +++ b/src/auth/urls.py @@ -3,7 +3,7 @@ import os import urllib.parse -import requests # TODO: make this async +import httpx import xmltodict from fastapi import APIRouter, BackgroundTasks, HTTPException, Request, Response from fastapi.responses import JSONResponse, RedirectResponse @@ -54,7 +54,9 @@ async def login_user( service_url = body.service service = urllib.parse.quote(service_url) service_validate_url = f"https://cas.sfu.ca/cas/serviceValidate?service={service}&ticket={body.ticket}" - cas_response = xmltodict.parse(requests.get(service_validate_url).text) + async with httpx.AsyncClient() as client: + response = await client.get(service_validate_url) + cas_response = xmltodict.parse(response.text) if "cas:authenticationFailure" in cas_response["cas:serviceResponse"]: _logger.info(f"User failed to login, with response {cas_response}") diff --git a/src/database.py b/src/database.py index 366916c..0d779aa 100644 --- a/src/database.py +++ b/src/database.py @@ -5,6 +5,7 @@ from typing import Annotated, Any import asyncpg +import httpx import sqlalchemy from fastapi import Depends, FastAPI from sqlalchemy import MetaData @@ -115,7 +116,9 @@ async def lifespan(app: FastAPI): """ Handles startup and shutdown events, see https://fastapi.tiangolo.com/advanced/events/ """ + app.state.http_client = httpx.AsyncClient() yield + await app.state.http_client.aclose() if sessionmanager._engine is not None: # Close the DB connection await sessionmanager.close()