Skip to content
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
22 changes: 12 additions & 10 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
---
name: Checking code quality

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:

ci-qlty:

runs-on: ubuntu-latest

container: fedorapython/fedora-python-tox:latest

strategy:
fail-fast: false
matrix:
tox-env: ["py312","py313"]

steps:

- name: Checkout the codebase current state
uses: actions/checkout@v4

- name: Install the base dependencies
run: |
python3 -m pip install --upgrade poetry tox
run: python3 -m pip install --upgrade poetry tox

- name: Check the correctness of the project config
run: |
poetry check
run: poetry check

- name: Check the quality of the code
run: |
tox -e cleaning
run: tox -e cleaning
19 changes: 10 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
---
name: Checking code functionality

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:

ci-qlty:

runs-on: ubuntu-latest

container: fedorapython/fedora-python-tox:latest

strategy:
fail-fast: false
matrix:
tox-env: ["py312"]
tox-env: ["py312","py313"]

steps:

- name: Checkout the codebase current state
uses: actions/checkout@v4

- name: Install the base dependencies
run: |
python3 -m pip install --upgrade poetry tox
run: python3 -m pip install --upgrade poetry tox

- name: Copy the default database, server and alembic configuration files
run: |
mv fastapi_ecom/config/config.py.example fastapi_ecom/config/config.py
mv fastapi_ecom/migrations/alembic.ini.example fastapi_ecom/migrations/alembic.ini

- name: Check the functionality of the code
run: |
tox -e ${{ matrix.tox-env }}
run: tox -e ${{ matrix.tox-env }}
4 changes: 1 addition & 3 deletions fastapi_ecom/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict

import uvicorn
from fastapi import FastAPI

Expand All @@ -25,7 +23,7 @@
PREFIX = "/api/v1"

@app.get("/")
def root() -> Dict[str, str]:
def root() -> dict[str, str]:
"""
Root endpoint of the FastAPI application.

Expand Down
2 changes: 1 addition & 1 deletion fastapi_ecom/database/db_setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import AsyncGenerator
from collections.abc import AsyncGenerator

from alembic import command, config
from sqlalchemy.ext.asyncio import AsyncSession
Expand Down
4 changes: 2 additions & 2 deletions fastapi_ecom/database/pydantic_schemas/business.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import List, Optional
from typing import Optional

from pydantic import BaseModel, EmailStr

Expand Down Expand Up @@ -103,4 +103,4 @@ class BusinessManyResult(APIResult):

:ivar businesses: List of businesses with their details.
"""
businesses: List[BusinessView] = []
businesses: list[BusinessView] = []
4 changes: 2 additions & 2 deletions fastapi_ecom/database/pydantic_schemas/customer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import List, Optional
from typing import Optional

from pydantic import BaseModel, EmailStr

Expand Down Expand Up @@ -103,4 +103,4 @@ class CustomerManyResult(APIResult):

:ivar customers: List of customer details.
"""
customers: List[CustomerView] = []
customers: list[CustomerView] = []
13 changes: 6 additions & 7 deletions fastapi_ecom/database/pydantic_schemas/order.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime
from typing import List

from pydantic import BaseModel

Expand Down Expand Up @@ -35,7 +34,7 @@ class OrderCreate(OrderBase):
:ivar order_items: List of order details, including product information and quantity.
"""
order_date: datetime
order_items: List[OrderDetailsCreate]
order_items: list[OrderDetailsCreate]


class OrderView(OrderCreate):
Expand All @@ -49,7 +48,7 @@ class OrderView(OrderCreate):
"""
uuid: str
total_price: float
order_items: List[OrderDetailsView]
order_items: list[OrderDetailsView]


class OrderViewInternal(OrderView):
Expand All @@ -62,11 +61,11 @@ class OrderViewInternal(OrderView):
identifiers.
"""
user_id: str
order_items: List[OrderDetailsViewInternal]
order_items: list[OrderDetailsViewInternal]


# class OrderUpdate(BaseModel):
# order_items: Optional[List[OrderDetailsUpdate]]
# order_items: Optional[list[OrderDetailsUpdate]]


class OrderResult(APIResult):
Expand All @@ -93,7 +92,7 @@ class OrderManyResult(APIResult):

:ivar orders: List of orders with detailed information.
"""
orders: List[OrderView] = []
orders: list[OrderView] = []


class OrderManyResultInternal(APIResult):
Expand All @@ -102,4 +101,4 @@ class OrderManyResultInternal(APIResult):

:ivar orders: List of orders with detailed internal information.
"""
orders: List[OrderViewInternal] = []
orders: list[OrderViewInternal] = []
6 changes: 3 additions & 3 deletions fastapi_ecom/database/pydantic_schemas/product.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import List, Optional
from typing import Optional

from pydantic import BaseModel

Expand Down Expand Up @@ -117,7 +117,7 @@ class ProductManyResult(APIResult):

:ivar products: List of products with detailed information.
"""
products: List[ProductView] = []
products: list[ProductView] = []


class ProductManyResultInternal(APIResult):
Expand All @@ -126,4 +126,4 @@ class ProductManyResultInternal(APIResult):

:ivar products: List of products with detailed internal information.
"""
products: List[ProductViewInternal] = []
products: list[ProductViewInternal] = []
5 changes: 2 additions & 3 deletions fastapi_ecom/migrations/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import List, Set

from alembic import command, config, runtime, script

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

def _get_current(self) -> Set[str]:
def _get_current(self) -> set[str]:
"""
Retrieve the current database revision(s).

Expand All @@ -49,7 +48,7 @@ def _get_current(self) -> Set[str]:

curtrevs = set()

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Create Date: 2024-08-11 13:25:16.313148

"""
from typing import Sequence, Union
from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Create Date: 2024-07-26 22:01:52.223573

"""
from typing import Sequence, Union
from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Create Date: 2024-10-31 16:03:13.152354

"""
from typing import Sequence, Union
from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Create Date: 2024-07-26 22:47:38.245376

"""
from typing import Sequence, Union
from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Create Date: 2024-07-30 20:05:56.484586

"""
from typing import Sequence, Union
from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Create Date: 2024-07-26 22:07:29.440283

"""
from typing import Sequence, Union
from collections.abc import Sequence
from typing import Union

import sqlalchemy as sa
from alembic import op
Expand Down
3 changes: 1 addition & 2 deletions fastapi_ecom/router/business.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime, timezone
from typing import Dict
from uuid import uuid4

import bcrypt
Expand Down Expand Up @@ -70,7 +69,7 @@ async def create_business(business: BusinessCreate, db: AsyncSession = Depends(g
}

@router.get("/me", status_code=status.HTTP_200_OK, tags=["business"])
async def get_business_me(business_auth = Depends(verify_business_cred)) -> Dict[str, str]:
async def get_business_me(business_auth = Depends(verify_business_cred)) -> dict[str, str]:
"""
Endpoint to fetch the email of the currently authenticated business.

Expand Down
3 changes: 1 addition & 2 deletions fastapi_ecom/router/customer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime, timezone
from typing import Dict
from uuid import uuid4

import bcrypt
Expand Down Expand Up @@ -70,7 +69,7 @@ async def create_customer(customer: CustomerCreate, db: AsyncSession = Depends(g
}

@router.get("/me", status_code=status.HTTP_200_OK, tags=["customer"])
async def get_customer_me(customer_auth = Depends(verify_cust_cred)) -> Dict[str, str]:
async def get_customer_me(customer_auth = Depends(verify_cust_cred)) -> dict[str, str]:
"""
Endpoint to fetch the email of the currently authenticated customer.

Expand Down
Loading