mirror of
https://github.com/flibusta-apps/telegram_files_server.git
synced 2025-12-06 12:35:39 +01:00
Migrate to ruff
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
from logging.config import fileConfig
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -7,15 +6,13 @@ from sqlalchemy.engine import create_engine
|
||||
|
||||
from core.db import DATABASE_URL
|
||||
|
||||
|
||||
myPath = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, myPath + "/../../")
|
||||
|
||||
config = context.config
|
||||
|
||||
|
||||
from app.models import BaseMeta
|
||||
|
||||
from app.models import BaseMeta # noqa: E402
|
||||
|
||||
target_metadata = BaseMeta.metadata
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from fastapi import Security, HTTPException, status
|
||||
from fastapi import HTTPException, Security, status
|
||||
|
||||
from core.auth import default_security
|
||||
from core.config import env_config
|
||||
|
||||
@@ -3,7 +3,7 @@ from enum import Enum
|
||||
|
||||
import ormar
|
||||
|
||||
from core.db import metadata, database
|
||||
from core.db import database, metadata
|
||||
|
||||
|
||||
class BaseMeta(ormar.ModelMeta):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from app.models import UploadBackends
|
||||
from app.services.storages import StoragesContainer, BotStorage, UserStorage
|
||||
from app.services.storages import BotStorage, StoragesContainer, UserStorage
|
||||
|
||||
|
||||
class FileDownloader:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from typing import Optional, Any
|
||||
from typing import Any, Optional
|
||||
|
||||
from fastapi import UploadFile
|
||||
|
||||
from app.models import UploadedFile, UploadBackends
|
||||
from app.services.storages import StoragesContainer, BotStorage, UserStorage
|
||||
from app.models import UploadBackends, UploadedFile
|
||||
from app.services.storages import BotStorage, StoragesContainer, UserStorage
|
||||
|
||||
|
||||
class Wrapper:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import abc
|
||||
from typing import AsyncIterator, Union, Optional
|
||||
from typing import AsyncIterator, Optional, Union
|
||||
|
||||
import telethon.client
|
||||
import telethon.errors
|
||||
@@ -9,7 +8,7 @@ import telethon.tl.types
|
||||
from core.config import env_config
|
||||
|
||||
|
||||
class BaseStorage(abc.ABC):
|
||||
class BaseStorage:
|
||||
def __init__(
|
||||
self, channel_id: Union[str, int], app_id: int, api_hash: str, session: str
|
||||
):
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import File, UploadFile, Depends, Form, APIRouter, HTTPException, status
|
||||
from fastapi import APIRouter, Depends, File, Form, HTTPException, UploadFile, status
|
||||
from fastapi.responses import StreamingResponse
|
||||
|
||||
from app.depends import check_token
|
||||
from app.models import UploadedFile as UploadedFileDB
|
||||
from app.serializers import UploadedFile, CreateUploadedFile
|
||||
from app.serializers import CreateUploadedFile, UploadedFile
|
||||
from app.services.file_downloader import FileDownloader
|
||||
from app.services.file_uploader import FileUploader
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/api/v1/files", dependencies=[Depends(check_token)], tags=["files"]
|
||||
)
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import sentry_sdk
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import ORJSONResponse
|
||||
|
||||
from prometheus_fastapi_instrumentator import Instrumentator
|
||||
import sentry_sdk
|
||||
|
||||
from app.on_start import on_start
|
||||
from app.views import router, healthcheck_router
|
||||
from app.views import healthcheck_router, router
|
||||
from core.config import env_config
|
||||
from core.db import database
|
||||
|
||||
|
||||
sentry_sdk.init(
|
||||
env_config.SENTRY_DSN,
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from fastapi.security import APIKeyHeader
|
||||
|
||||
|
||||
default_security = APIKeyHeader(name="Authorization")
|
||||
|
||||
@@ -2,7 +2,6 @@ from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, BaseSettings
|
||||
|
||||
|
||||
BotToken = str
|
||||
TelethonSessionName = str
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ from sqlalchemy import MetaData
|
||||
|
||||
from core.config import env_config
|
||||
|
||||
|
||||
DATABASE_URL = (
|
||||
f"postgresql://{env_config.POSTGRES_USER}:{quote(env_config.POSTGRES_PASSWORD)}@"
|
||||
f"{env_config.POSTGRES_HOST}:{env_config.POSTGRES_PORT}/{env_config.POSTGRES_DB}"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from core.app import start_app
|
||||
|
||||
|
||||
app = start_app()
|
||||
|
||||
Reference in New Issue
Block a user