Linted .py files
This commit is contained in:
@@ -1,20 +1,21 @@
|
|||||||
import os
|
|
||||||
import sys
|
|
||||||
import pathlib
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import sys
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
from alembic import context
|
|
||||||
from sqlalchemy import pool
|
from sqlalchemy import pool
|
||||||
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
|
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
|
||||||
|
|
||||||
|
from alembic import context
|
||||||
|
|
||||||
# Ensure project root is importable
|
# Ensure project root is importable
|
||||||
PROJECT_ROOT = pathlib.Path(__file__).resolve().parents[1]
|
PROJECT_ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||||
if str(PROJECT_ROOT) not in sys.path:
|
if str(PROJECT_ROOT) not in sys.path:
|
||||||
sys.path.insert(0, str(PROJECT_ROOT))
|
sys.path.insert(0, str(PROJECT_ROOT))
|
||||||
|
|
||||||
# Import metadata (should NOT import settings)
|
# Import metadata (should NOT import settings)
|
||||||
from app.db.base import Base # Base.metadata must include all models
|
from app.db.base import Base # Base.metadata must include all models # noqa: E402
|
||||||
|
|
||||||
# Alembic config & logging
|
# Alembic config & logging
|
||||||
config = context.config
|
config = context.config
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
# ruff was driving me crazy with imported not used, noqa on all of these..
|
# ruff was driving me crazy with imported not used, noqa on all of these..
|
||||||
from fastapi import Depends, HTTPException, status # noqa: F401
|
from fastapi import Depends, HTTPException, status # noqa: F401
|
||||||
from fastapi.security import HTTPBearer # noqa: F401
|
from fastapi.security import HTTPBearer # noqa: F401
|
||||||
from jose import jwt, JWTError # noqa: F401
|
from jose import JWTError, jwt # noqa: F401
|
||||||
|
from sqlalchemy import select # noqa: F401
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession # noqa: F401
|
||||||
|
|
||||||
from app.core.config import settings # noqa: F401
|
from app.core.config import settings # noqa: F401
|
||||||
from app.db.session import get_session # noqa: F401
|
from app.db.session import get_session # noqa: F401
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession # noqa: F401
|
|
||||||
from app.models.user import User # noqa: F401
|
from app.models.user import User # noqa: F401
|
||||||
from sqlalchemy import select # noqa: F401
|
|
||||||
|
|
||||||
bearer = HTTPBearer()
|
bearer = HTTPBearer()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
model_config = SettingsConfigDict(
|
model_config = SettingsConfigDict(
|
||||||
env_file=".env",
|
env_file=".env",
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
from jose import jwt
|
from jose import jwt
|
||||||
from passlib.hash import argon2
|
from passlib.hash import argon2
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
|
|
||||||
ALGO = "HS256"
|
ALGO = "HS256"
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
from app.models.user import User
|
|
||||||
from app.models.server import Server
|
|
||||||
from app.models.sshkey import SSHKey
|
|
||||||
from app.models.access_request import AccessRequest
|
|
||||||
from app.models.audit import AuditEvent
|
|
||||||
|
|
||||||
from sqlalchemy.orm import declarative_base
|
from sqlalchemy.orm import declarative_base
|
||||||
|
|
||||||
|
from app.models.access_request import AccessRequest # noqa: F401
|
||||||
|
from app.models.audit import AuditEvent # noqa: F401
|
||||||
|
from app.models.server import Server # noqa: F401
|
||||||
|
from app.models.sshkey import SSHKey # noqa: F401
|
||||||
|
from app.models.user import User # noqa: F401
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
|
|
||||||
engine = create_async_engine(settings.POSTGRES_DSN, echo=False, future=True)
|
engine = create_async_engine(settings.POSTGRES_DSN, echo=False, future=True)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from app.core.config import settings
|
|
||||||
from app.api.v1 import auth, keys
|
from app.api.v1 import auth, keys
|
||||||
|
from app.core.config import settings
|
||||||
|
|
||||||
app = FastAPI(title=settings.PROJECT_NAME)
|
app = FastAPI(title=settings.PROJECT_NAME)
|
||||||
app.include_router(auth.router, prefix=f"{settings.API_V1_STR}/auth", tags=["auth"])
|
app.include_router(auth.router, prefix=f"{settings.API_V1_STR}/auth", tags=["auth"])
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from sqlalchemy import ForeignKey, String, DateTime
|
from datetime import datetime, timezone #noqa
|
||||||
|
|
||||||
|
from sqlalchemy import DateTime, ForeignKey, String
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
from datetime import datetime, timezone
|
|
||||||
from app.models.user import Base
|
from app.models.user import Base
|
||||||
|
|
||||||
|
|
||||||
class AccessRequest(Base):
|
class AccessRequest(Base):
|
||||||
__tablename__ = "access_requests"
|
__tablename__ = "access_requests"
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from sqlalchemy.orm import Mapped, mapped_column
|
|
||||||
from sqlalchemy import String, DateTime
|
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
from sqlalchemy import DateTime, String
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from app.models.user import Base
|
from app.models.user import Base
|
||||||
|
|
||||||
|
|
||||||
class AuditEvent(Base):
|
class AuditEvent(Base):
|
||||||
__tablename__ = "audit_events"
|
__tablename__ = "audit_events"
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
from sqlalchemy import JSON, Boolean, Integer, String
|
||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
from sqlalchemy import String, JSON, Boolean, Integer
|
|
||||||
from app.models.user import Base
|
from app.models.user import Base
|
||||||
|
|
||||||
|
|
||||||
class Server(Base):
|
class Server(Base):
|
||||||
__tablename__ = "servers"
|
__tablename__ = "servers"
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
from sqlalchemy import ForeignKey, String, DateTime, Boolean
|
from datetime import datetime, timezone # noqa: F401
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
||||||
from datetime import datetime, timezone
|
from sqlalchemy import Boolean, DateTime, ForeignKey, String
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship # noqa: F401
|
||||||
|
|
||||||
from app.models.user import Base
|
from app.models.user import Base
|
||||||
|
|
||||||
|
|
||||||
class SSHKey(Base):
|
class SSHKey(Base):
|
||||||
__tablename__ = "ssh_keys"
|
__tablename__ = "ssh_keys"
|
||||||
id: Mapped[int] = mapped_column(primary_key=True)
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from sqlalchemy.orm import Mapped, mapped_column
|
from sqlalchemy import Boolean, String
|
||||||
from sqlalchemy import String, Boolean
|
from sqlalchemy.orm import Mapped, declarative_base, mapped_column
|
||||||
from app.db.session import engine # only for Alembic discovery, not used here
|
|
||||||
from sqlalchemy.orm import declarative_base
|
# only for Alembic discovery, not used here
|
||||||
|
from app.db.session import engine # noqa: F401
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
class User(Base):
|
class User(Base):
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
# Tiny test to pass CI, just checks the health endpoint to ensure API running.
|
# Tiny test to pass CI, just checks the health endpoint to ensure API running.
|
||||||
#
|
#
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from app.main import app
|
from app.main import app
|
||||||
|
|
||||||
|
|
||||||
def test_healthz():
|
def test_healthz():
|
||||||
client = TestClient(app)
|
client = TestClient(app)
|
||||||
r = client.get("/healthz")
|
r = client.get("/healthz")
|
||||||
Reference in New Issue
Block a user