Skip to content

Commit

Permalink
pass ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanMT committed Jul 22, 2024
1 parent be98bff commit d138fc7
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/py_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
pip install ruff==0.1.11
pip install ruff==0.5.2
- name: Analysing the code with ruff
run: |
ruff check backend
4 changes: 2 additions & 2 deletions backend/app/apis/github_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from asyncio import TimeoutError, sleep
from datetime import datetime

from aiohttp import ClientConnectorError, ClientSession
from dateutil.parser import parse
from aiohttp import ClientSession, ClientConnectorError
from asyncio import TimeoutError, sleep

from app.config import settings

Expand Down
5 changes: 2 additions & 3 deletions backend/app/apis/managers/mvn_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Any

from aiohttp import ClientSession, ClientConnectorError
from asyncio import TimeoutError, sleep
from typing import Any

from aiohttp import ClientConnectorError, ClientSession
from xmltodict import parse


Expand Down
4 changes: 2 additions & 2 deletions backend/app/apis/managers/npm_service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from asyncio import TimeoutError, sleep
from json import JSONDecodeError
from typing import Any

from aiohttp import ClientSession, ClientConnectorError
from asyncio import TimeoutError, sleep
from aiohttp import ClientConnectorError, ClientSession


async def get_all_npm_versions(pkg_name: str) -> Any:
Expand Down
4 changes: 2 additions & 2 deletions backend/app/apis/managers/pip_service.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from asyncio import TimeoutError, sleep
from json import JSONDecodeError
from typing import Any

from aiohttp import ClientConnectorError, ClientSession
from dateutil.parser import parse
from aiohttp import ClientSession, ClientConnectorError
from asyncio import TimeoutError, sleep

from app.utils import get_first_position, parse_pip_constraints

Expand Down
5 changes: 2 additions & 3 deletions backend/app/controllers/auth_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import datetime
from typing import Annotated

from fastapi import APIRouter, Body, status, Depends
from fastapi import APIRouter, Body, Depends, status
from fastapi.responses import JSONResponse

from app.models import (
Expand All @@ -17,12 +16,12 @@
update_user_password,
)
from app.utils import (
JWTBearer,
create_access_token,
get_hashed_password,
json_encoder,
verify_access_token,
verify_password,
JWTBearer,
)

router = APIRouter()
Expand Down
4 changes: 2 additions & 2 deletions backend/app/controllers/config_operation_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import APIRouter, Body, status, Depends
from fastapi import APIRouter, Body, Depends, status
from fastapi.encoders import jsonable_encoder
from fastapi.responses import JSONResponse
from flamapy.metamodels.smt_metamodel.operations import (
Expand All @@ -18,7 +18,7 @@
read_smt_text,
replace_smt_text,
)
from app.utils import json_encoder, JWTBearer
from app.utils import JWTBearer, json_encoder

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions backend/app/controllers/file_operation_controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Annotated

from fastapi import APIRouter, Body, status, Depends
from fastapi import APIRouter, Body, Depends, status
from fastapi.encoders import jsonable_encoder
from fastapi.responses import JSONResponse
from flamapy.metamodels.smt_metamodel.operations import (
Expand All @@ -25,7 +25,7 @@
read_smt_text,
replace_smt_text,
)
from app.utils import json_encoder, JWTBearer
from app.utils import JWTBearer, json_encoder

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions backend/app/controllers/graph_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime, timedelta
from typing import Any

from fastapi import APIRouter, BackgroundTasks, status, Depends
from fastapi import APIRouter, BackgroundTasks, Depends, status
from fastapi.responses import JSONResponse
from pytz import UTC

Expand All @@ -25,7 +25,7 @@
update_requirement_file_moment,
update_requirement_rel_constraints,
)
from app.utils import json_encoder, repo_analyzer, JWTBearer
from app.utils import JWTBearer, json_encoder, repo_analyzer

from .managers.mvn_generate_controller import (
mvn_create_package,
Expand Down
3 changes: 2 additions & 1 deletion backend/app/controllers/health_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from fastapi import APIRouter, status
from fastapi.responses import JSONResponse

from app.utils import json_encoder

router = APIRouter()
Expand All @@ -8,4 +9,4 @@
def health_check():
return JSONResponse(
status_code=status.HTTP_200_OK, content=json_encoder({"status": "healthy"})
)
)
2 changes: 1 addition & 1 deletion backend/app/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"relate_packages",
"update_package_moment",
"create_repository",
"create_user_repository_rel"
"create_user_repository_rel",
"read_repositories_update",
"read_repositories",
"read_repository_by_id",
Expand Down
6 changes: 5 additions & 1 deletion backend/app/services/dbs/databases.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from functools import lru_cache

from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorCollection, AsyncIOMotorDatabase
from motor.motor_asyncio import (
AsyncIOMotorClient,
AsyncIOMotorCollection,
AsyncIOMotorDatabase,
)
from neo4j import AsyncDriver, AsyncGraphDatabase

from app.config import settings
Expand Down
2 changes: 1 addition & 1 deletion backend/app/services/login_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from .dbs.databases import get_graph_db_driver, get_collection
from .dbs.databases import get_collection, get_graph_db_driver


async def create_user(user: dict[str, str]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion backend/app/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .get_first_pos import get_first_position
from .json_encoder import json_encoder
from .jwt_encoder import (
JWTBearer,
create_access_token,
verify_access_token,
JWTBearer,
)
from .metrics import mean, weighted_mean
from .parse_pip_constraints import parse_pip_constraints
Expand Down
10 changes: 4 additions & 6 deletions backend/app/utils/jwt_encoder.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from datetime import datetime, timedelta

from fastapi import HTTPException, Request
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from jose import jwt
from jose.exceptions import JWTError
from jwt.exceptions import InvalidTokenError

from app.config import settings

from fastapi import Request, HTTPException
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials



async def create_access_token(subject: str, expires_delta: int | None = None) -> str:
if expires_delta is not None:
Expand All @@ -31,10 +29,10 @@ def verify_access_token(access_token: str) -> bool:

class JWTBearer(HTTPBearer):
def __init__(self, auto_error: bool = True):
super(JWTBearer, self).__init__(auto_error=auto_error)
super().__init__(auto_error=auto_error)

async def __call__(self, request: Request):
credentials: HTTPAuthorizationCredentials | None = await super(JWTBearer, self).__call__(request)
credentials: HTTPAuthorizationCredentials | None = await super().__call__(request)
if credentials:
if not credentials.scheme == "Bearer":
raise HTTPException(status_code=403, detail="Invalid authentication scheme.")
Expand Down
1 change: 0 additions & 1 deletion backend/requirements_dev.txt

This file was deleted.

0 comments on commit d138fc7

Please sign in to comment.