diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff6c31a..79598bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,23 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.3 + rev: v0.4.1 hooks: - id: ruff + args: [--fix] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: "v1.9.0" hooks: - id: mypy - args: [--strict, --ignore-missing-imports] + args: [--strict] additional_dependencies: - "pydantic" - "fastapi" - "sqlalchemy" + - "pytest" diff --git a/README.md b/README.md index fedd70b..4aad4fa 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,4 @@ poetry run pytest -s --pdb # helpful for debugging tests ```sh sudo docker compose -f docker-compose.yml -p expenses_server down --remove-orphans --volumes -``` \ No newline at end of file +``` diff --git a/expenses_server/db_models/expense.py b/expenses_server/db_models/expense.py index cf69e5c..120e441 100644 --- a/expenses_server/db_models/expense.py +++ b/expenses_server/db_models/expense.py @@ -1,5 +1,5 @@ from uuid import uuid4, UUID -from sqlalchemy import TIMESTAMP, ForeignKey, Text, func, types, text +from sqlalchemy import TIMESTAMP, ForeignKey, Text, func, types from sqlalchemy.orm import relationship, Mapped, mapped_column from .core import Base from typing import TYPE_CHECKING diff --git a/expenses_server/dtos/expenses.py b/expenses_server/dtos/expenses.py index fa9878a..f273092 100644 --- a/expenses_server/dtos/expenses.py +++ b/expenses_server/dtos/expenses.py @@ -1,6 +1,5 @@ from datetime import datetime -from typing import Annotated -from pydantic import UUID4, BaseModel, Field, computed_field, field_serializer +from pydantic import UUID4, BaseModel, field_serializer from .categories import Category from .accounts import Account from .currencies import CurrencyEnum diff --git a/expenses_server/routes/expenses.py b/expenses_server/routes/expenses.py index d7f0fe8..3f824cf 100644 --- a/expenses_server/routes/expenses.py +++ b/expenses_server/routes/expenses.py @@ -1,4 +1,3 @@ -from curses.panel import update_panels from http import HTTPStatus from typing import cast from fastapi import APIRouter, Depends, HTTPException diff --git a/expenses_server/tests/conftest.py b/expenses_server/tests/conftest.py index 521ce5a..6325a2f 100644 --- a/expenses_server/tests/conftest.py +++ b/expenses_server/tests/conftest.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Generator +from typing import Any, Generator from fastapi.testclient import TestClient import pytest from expenses_server.main import app @@ -15,7 +15,7 @@ def test_client() -> Generator[TestClient, None, None]: @pytest.fixture() def test_expenses( test_client: TestClient, -) -> Generator[tuple[TestClient, list[dict]], None, None]: +) -> Generator[tuple[TestClient, list[dict[str, Any]]], None, None]: expense1 = create_mock_expense(test_client) print("EXPENSE1", expense1) expense2 = create_mock_expense(test_client, extra={"account_id": 2}) diff --git a/expenses_server/tests/test_delete_expense.py b/expenses_server/tests/test_delete_expense.py index eb27868..5c0378a 100644 --- a/expenses_server/tests/test_delete_expense.py +++ b/expenses_server/tests/test_delete_expense.py @@ -1,8 +1,11 @@ from http import HTTPStatus +from typing import Any from fastapi.testclient import TestClient -def test_delete_expenses(test_expenses: tuple[TestClient, list[dict]]) -> None: +def test_delete_expenses( + test_expenses: tuple[TestClient, list[dict[str, Any]]], +) -> None: client, mock_expenses = test_expenses expense_id = mock_expenses[0]["id"] response = client.delete(f"/api/expenses/{expense_id}") diff --git a/expenses_server/tests/test_get_expense.py b/expenses_server/tests/test_get_expense.py index 8366fc8..ad5620d 100644 --- a/expenses_server/tests/test_get_expense.py +++ b/expenses_server/tests/test_get_expense.py @@ -1,7 +1,8 @@ +from typing import Any from fastapi.testclient import TestClient -def test_get_expense(test_expenses: tuple[TestClient, list[dict]]) -> None: +def test_get_expense(test_expenses: tuple[TestClient, list[dict[str, Any]]]) -> None: client, mock_expenses = test_expenses expense_id = mock_expenses[0]["id"] response = client.get(f"/api/expenses/{expense_id}") diff --git a/expenses_server/tests/test_update_expense.py b/expenses_server/tests/test_update_expense.py index 4b89495..21f51df 100644 --- a/expenses_server/tests/test_update_expense.py +++ b/expenses_server/tests/test_update_expense.py @@ -1,8 +1,9 @@ +from typing import Any from fastapi.testclient import TestClient import copy -def test_update_expense(test_expenses: tuple[TestClient, list[dict]]) -> None: +def test_update_expense(test_expenses: tuple[TestClient, list[dict[str, Any]]]) -> None: client, mock_expenses = test_expenses expense_before_update = mock_expenses[0] diff --git a/expenses_server/tests/utils.py b/expenses_server/tests/utils.py index 9ca1476..e39d5fc 100644 --- a/expenses_server/tests/utils.py +++ b/expenses_server/tests/utils.py @@ -4,7 +4,7 @@ def create_mock_expense( client: TestClient, extra: dict[str, Any] | None = None -) -> dict: +) -> dict[str, Any]: payload = ( { "amount": 10, @@ -25,4 +25,4 @@ def create_mock_expense( ) response = client.post("/api/expenses", json=payload) assert response.status_code == 200 - return cast(dict, response.json()) + return cast(dict[str, Any], response.json())