Skip to content

Commit f04ff2c

Browse files
committed
remove typing imports and uvicorn dependency
1 parent c7a91de commit f04ff2c

File tree

7 files changed

+11
-19
lines changed

7 files changed

+11
-19
lines changed

backend/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,4 @@ to run the unit tests for the backend app.
4545

4646
The project uses Pydantic's settings management through FastAPI. Documentation on how the settings work is availabe [here](https://fastapi.tiangolo.com/advanced/settings/).
4747

48-
The configuration file is located in [config/config.py](app/config/config.py). This file defines the setting properties, there types, and default values. The `Config` class specifies where these properties are from, i.e. the [.env.dev](.env.dev) file. Modify the values in the [.env.dev](.env.dev) file to change the configuration.
49-
50-
Note that when the backend application is run with Docker, the values in the [.env.dev](.env.dev) are overriden with environment variables set in the Docker configuration.
48+
The configuration file is located in [config/config.py](app/config/config.py). This file defines the setting properties, their types, and default values. The `model_config` attribute specifies where these properties are from, i.e. the [.env](../.env) file at the root of the project. Modify the values in the [.env](../.env) file to change the configuration.

backend/app/config/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import secrets
2-
from typing import List, Literal
2+
from typing import Literal
33

44
from pydantic import AnyHttpUrl, EmailStr
55
from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -19,7 +19,7 @@ class Settings(BaseSettings):
1919
# 60 minutes * 24 hours * 8 days = 8 days
2020
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
2121
# JSON-formatted list of origins
22-
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
22+
BACKEND_CORS_ORIGINS: list[AnyHttpUrl] = []
2323
PROJECT_NAME: str
2424
FIRST_SUPERUSER: EmailStr
2525
FIRST_SUPERUSER_PASSWORD: str

backend/app/routers/users.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List, Optional
1+
from typing import Any
22
from uuid import UUID
33

44
from beanie.exceptions import RevisionIdWasChanged
@@ -42,10 +42,10 @@ async def register_user(
4242
)
4343

4444

45-
@router.get("", response_model=List[schemas.User])
45+
@router.get("", response_model=list[schemas.User])
4646
async def get_users(
47-
limit: Optional[int] = 10,
48-
offset: Optional[int] = 0,
47+
limit: int | None = 10,
48+
offset: int | None = 0,
4949
admin_user: models.User = Depends(get_current_active_superuser),
5050
):
5151
users = await models.User.find_all().skip(offset).limit(limit).to_list()

backend/pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ python = "^3.12"
1515
requests = "^2.32.3"
1616
pymongo = "^4.9.2"
1717
fastapi = {extras = ["standard"], version = "^0.115.0"}
18-
uvicorn = "^0.31.0"
1918
python-multipart = "^0.0.12"
2019
motor = "^3.6.0"
2120
pydantic = "^2.9.2"

backend/tests/routers/test_login.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Dict
2-
31
import pytest
42
from httpx import AsyncClient
53

@@ -21,7 +19,7 @@ async def test_get_access_token(client: AsyncClient) -> None:
2119

2220
@pytest.mark.anyio
2321
async def test_use_access_token(
24-
client: AsyncClient, superuser_token_headers: Dict[str, str]
22+
client: AsyncClient, superuser_token_headers: dict[str, str]
2523
) -> None:
2624
r = await client.get(
2725
f"{settings.API_V1_STR}/login/test-token",

backend/tests/routers/test_users.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Dict
2-
31
import pytest
42
from httpx import AsyncClient
53

@@ -16,7 +14,7 @@
1614

1715
@pytest.mark.anyio
1816
async def test_get_profile_superuser(
19-
client: AsyncClient, superuser_token_headers: Dict[str, str]
17+
client: AsyncClient, superuser_token_headers: dict[str, str]
2018
) -> None:
2119
r = await client.get(
2220
f"{settings.API_V1_STR}/users/me", headers=superuser_token_headers

backend/tests/utils.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import random
22
import string
3-
from typing import Dict
43

54
from httpx import AsyncClient
65

@@ -11,7 +10,7 @@
1110

1211
async def get_user_auth_headers(
1312
client: AsyncClient, email: str, password: str
14-
) -> Dict[str, str]:
13+
) -> dict[str, str]:
1514
"""
1615
Given a user's email and password, send a request to login the user and return the
1716
authorization headers.
@@ -24,7 +23,7 @@ async def get_user_auth_headers(
2423
return headers
2524

2625

27-
async def generate_user_auth_headers(client: AsyncClient, user: User) -> Dict[str, str]:
26+
async def generate_user_auth_headers(client: AsyncClient, user: User) -> dict[str, str]:
2827
"""
2928
Given a user in DB, generate a token and return the authorization headers.
3029
"""

0 commit comments

Comments
 (0)