Skip to content

Commit 9e72d3b

Browse files
committed
Uitilise latest ruff standards
Signed-off-by: Shounak Dey <shounakdey@ymail.com>
1 parent d5fea8f commit 9e72d3b

28 files changed

Lines changed: 48 additions & 61 deletions

fastapi_ecom/app.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Dict
2-
31
import uvicorn
42
from fastapi import FastAPI
53

@@ -25,7 +23,7 @@
2523
PREFIX = "/api/v1"
2624

2725
@app.get("/")
28-
def root() -> Dict[str, str]:
26+
def root() -> dict[str, str]:
2927
"""
3028
Root endpoint of the FastAPI application.
3129

fastapi_ecom/database/db_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import AsyncGenerator
1+
from collections.abc import AsyncGenerator
22

33
from alembic import command, config
44
from sqlalchemy.ext.asyncio import AsyncSession

fastapi_ecom/database/pydantic_schemas/business.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import List, Optional
2+
from typing import Optional
33

44
from pydantic import BaseModel, EmailStr
55

@@ -103,4 +103,4 @@ class BusinessManyResult(APIResult):
103103
104104
:ivar businesses: List of businesses with their details.
105105
"""
106-
businesses: List[BusinessView] = []
106+
businesses: list[BusinessView] = []

fastapi_ecom/database/pydantic_schemas/customer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import List, Optional
2+
from typing import Optional
33

44
from pydantic import BaseModel, EmailStr
55

@@ -103,4 +103,4 @@ class CustomerManyResult(APIResult):
103103
104104
:ivar customers: List of customer details.
105105
"""
106-
customers: List[CustomerView] = []
106+
customers: list[CustomerView] = []

fastapi_ecom/database/pydantic_schemas/order.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime
2-
from typing import List
32

43
from pydantic import BaseModel
54

@@ -35,7 +34,7 @@ class OrderCreate(OrderBase):
3534
:ivar order_items: List of order details, including product information and quantity.
3635
"""
3736
order_date: datetime
38-
order_items: List[OrderDetailsCreate]
37+
order_items: list[OrderDetailsCreate]
3938

4039

4140
class OrderView(OrderCreate):
@@ -49,7 +48,7 @@ class OrderView(OrderCreate):
4948
"""
5049
uuid: str
5150
total_price: float
52-
order_items: List[OrderDetailsView]
51+
order_items: list[OrderDetailsView]
5352

5453

5554
class OrderViewInternal(OrderView):
@@ -62,11 +61,11 @@ class OrderViewInternal(OrderView):
6261
identifiers.
6362
"""
6463
user_id: str
65-
order_items: List[OrderDetailsViewInternal]
64+
order_items: list[OrderDetailsViewInternal]
6665

6766

6867
# class OrderUpdate(BaseModel):
69-
# order_items: Optional[List[OrderDetailsUpdate]]
68+
# order_items: Optional[list[OrderDetailsUpdate]]
7069

7170

7271
class OrderResult(APIResult):
@@ -93,7 +92,7 @@ class OrderManyResult(APIResult):
9392
9493
:ivar orders: List of orders with detailed information.
9594
"""
96-
orders: List[OrderView] = []
95+
orders: list[OrderView] = []
9796

9897

9998
class OrderManyResultInternal(APIResult):
@@ -102,4 +101,4 @@ class OrderManyResultInternal(APIResult):
102101
103102
:ivar orders: List of orders with detailed internal information.
104103
"""
105-
orders: List[OrderViewInternal] = []
104+
orders: list[OrderViewInternal] = []

fastapi_ecom/database/pydantic_schemas/product.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import List, Optional
2+
from typing import Optional
33

44
from pydantic import BaseModel
55

@@ -117,7 +117,7 @@ class ProductManyResult(APIResult):
117117
118118
:ivar products: List of products with detailed information.
119119
"""
120-
products: List[ProductView] = []
120+
products: list[ProductView] = []
121121

122122

123123
class ProductManyResultInternal(APIResult):
@@ -126,4 +126,4 @@ class ProductManyResultInternal(APIResult):
126126
127127
:ivar products: List of products with detailed internal information.
128128
"""
129-
products: List[ProductViewInternal] = []
129+
products: list[ProductViewInternal] = []

fastapi_ecom/migrations/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import List, Set
21

32
from alembic import command, config, runtime, script
43

@@ -39,7 +38,7 @@ def create(self, comment: str, autogenerate: bool) -> None:
3938
"""
4039
command.revision(config=self.config, message=comment, autogenerate=autogenerate)
4140

42-
def _get_current(self) -> Set[str]:
41+
def _get_current(self) -> set[str]:
4342
"""
4443
Retrieve the current database revision(s).
4544
@@ -49,7 +48,7 @@ def _get_current(self) -> Set[str]:
4948

5049
curtrevs = set()
5150

52-
def _get_rev_current(rev: str, context: object) -> List:
51+
def _get_rev_current(rev: str, context: object) -> list:
5352
"""
5453
Callback function to retrieve the current revision(s) during the migration check.
5554

fastapi_ecom/migrations/versions/29f5c5a0304d_modify_date_field_mixin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Create Date: 2024-08-11 13:25:16.313148
66
77
"""
8-
from typing import Sequence, Union
8+
from collections.abc import Sequence
9+
from typing import Union
910

1011
import sqlalchemy as sa
1112
from alembic import op

fastapi_ecom/migrations/versions/306d801996a6_initial_model_setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Create Date: 2024-07-26 22:01:52.223573
66
77
"""
8-
from typing import Sequence, Union
8+
from collections.abc import Sequence
9+
from typing import Union
910

1011
import sqlalchemy as sa
1112
from alembic import op

fastapi_ecom/migrations/versions/60c8ccec25ac_create_and_update_date_with_relation_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Create Date: 2024-10-31 16:03:13.152354
66
77
"""
8-
from typing import Sequence, Union
8+
from collections.abc import Sequence
9+
from typing import Union
910

1011
import sqlalchemy as sa
1112
from alembic import op

0 commit comments

Comments
 (0)