Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test against more versions of Python in PR workflow #33

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ruff
name: PR checks
on:
pull_request:
jobs:
Expand All @@ -10,8 +10,15 @@ jobs:
mypy:
needs: ruff
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- run: sudo apt install libsystemd-dev
- run: pip install -r requirements.txt
- run: pip install mypy
- run: mypy --install-types --non-interactive --explicit-package-bases --disable-error-code import-untyped .
- run: pip install mypy==1.4.1 # 1.4.1 is the last version to support Python 3.7, which we run on AmpliPi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--disable-error-code import-untyped isn't valid for earlier versions of mypy, which are in turn necessary to support python 3.7

- run: mypy --install-types --non-interactive --explicit-package-bases --ignore-missing-imports .
5 changes: 3 additions & 2 deletions admin/cloud.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from os import getenv
from typing import List
from ipaddress import IPv4Address

from pydantic import UUID4
Expand Down Expand Up @@ -34,7 +35,7 @@ def get_ts_instance(tunnel_id: UUID4) -> compute_v1.Instance:
instance_client = compute_v1.InstancesClient()
return instance_client.get(project=PROJECT_ID, zone=ZONE, instance=f"{INSTANCE_NAME_PREFIX}-{tunnel_id}")

def list_ts_instances() -> list[compute_v1.Instance]:
def list_ts_instances() -> List[compute_v1.Instance]:
""" Lists tunnel server instances. At present, it just uses the
INSTANCE_NAME_PREFIX to determine if it is a tunnel server.
"""
Expand All @@ -53,7 +54,7 @@ def _create_ts_boot_disk() -> compute_v1.AttachedDisk:
disk.boot = True
return disk

def _create_ts_network_interfaces() -> list[compute_v1.NetworkInterface]:
def _create_ts_network_interfaces() -> List[compute_v1.NetworkInterface]:
""" create a list of network interface descriptions """
# create network interface & external access configs
netiface = compute_v1.NetworkInterface()
Expand Down
3 changes: 2 additions & 1 deletion api/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def get_tunnel_id(token: str = Depends(oauth2_scheme)) -> UUID:
try:
payload = TunnelRequestTokenData(
**jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGO]))
tunnel_id_str = payload.sub.removeprefix("tunnel_id:")
prefix_len = len("tunnel_id:")
tunnel_id_str = payload.sub[prefix_len:]
logging.debug(f"tunnel_id_str: {tunnel_id_str}")
tunnel_id = UUID(hex=tunnel_id_str)
except JWTError:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ systemd-python
wireguard-tools
sqlmodel==0.0.19
google-cloud-compute
cryptography==42.0.8
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addresses a CVE in <43.0.1

cryptography==43.0.3
google-cloud-secret-manager
cloud-sql-python-connector[pymysql]
Loading