Skip to content

Commit

Permalink
Apply examples/ tests/
Browse files Browse the repository at this point in the history
  • Loading branch information
waketzheng committed Jan 10, 2025
1 parent 1693463 commit 131cf24
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/fastapi/_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# pylint: disable=E0611,E0401
import multiprocessing
import os
from collections.abc import AsyncGenerator
from concurrent.futures import ProcessPoolExecutor
from contextlib import asynccontextmanager
from datetime import datetime
from pathlib import Path
from typing import AsyncGenerator, Tuple

import anyio
import pytest
Expand Down Expand Up @@ -74,7 +74,7 @@ async def create_user(self, async_client: AsyncClient) -> Users:
assert user_obj.id == user_id
return user_obj

async def user_list(self, async_client: AsyncClient) -> Tuple[datetime, Users, User_Pydantic]:
async def user_list(self, async_client: AsyncClient) -> tuple[datetime, Users, User_Pydantic]:
utc_now = datetime.now(pytz.utc)
user_obj = await Users.create(username="test")
response = await async_client.get("/users")
Expand Down
2 changes: 1 addition & 1 deletion examples/fastapi/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=E0611,E0401
import os
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from typing import AsyncGenerator

from fastapi import FastAPI
from routers import router as users_router
Expand Down
2 changes: 1 addition & 1 deletion examples/fastapi/main_custom_timezone.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pylint: disable=E0611,E0401
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from typing import AsyncGenerator

from config import register_orm
from fastapi import FastAPI
Expand Down
4 changes: 1 addition & 3 deletions examples/fastapi/routers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import List

from fastapi import APIRouter, HTTPException
from models import Users
from schemas import Status, User_Pydantic, UserIn_Pydantic

router = APIRouter()


@router.get("/users", response_model=List[User_Pydantic])
@router.get("/users", response_model=list[User_Pydantic])
async def get_users():
return await User_Pydantic.from_queryset(Users.all())

Expand Down
4 changes: 2 additions & 2 deletions examples/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This example demonstrates model signals usage
"""

from typing import List, Optional, Type
from typing import Optional, Type

from tortoise import BaseDBAsyncClient, Tortoise, fields, run_async
from tortoise.models import Model
Expand Down Expand Up @@ -33,7 +33,7 @@ async def signal_post_save(
instance: Signal,
created: bool,
using_db: "Optional[BaseDBAsyncClient]",
update_fields: List[str],
update_fields: list[str],
) -> None:
print(sender, instance, using_db, created, update_fields)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Type
from typing import Optional, Type

from tests.testmodels import Signals
from tortoise import BaseDBAsyncClient
Expand All @@ -20,7 +20,7 @@ async def signal_post_save(
instance: Signals,
created: bool,
using_db: "Optional[BaseDBAsyncClient]",
update_fields: List,
update_fields: list,
) -> None:
await Signals.filter(name="test2").update(name="test_post-save")
await Signals.filter(name="test6").update(name="test_post-save")
Expand Down
4 changes: 2 additions & 2 deletions tests/testmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import uuid
from decimal import Decimal
from enum import Enum, IntEnum
from typing import List, Union
from typing import Union

import pytz
from pydantic import BaseModel, ConfigDict
Expand Down Expand Up @@ -959,7 +959,7 @@ class OldStyleModel(Model):


def camelize_var(var_name: str):
var_parts: List[str] = var_name.split("_")
var_parts: list[str] = var_name.split("_")
return var_parts[0] + "".join([part.title() for part in var_parts[1:]])


Expand Down

0 comments on commit 131cf24

Please sign in to comment.