Skip to content

Commit 0561592

Browse files
fix: pre-commit check
1 parent 5db39dc commit 0561592

File tree

12 files changed

+45
-42
lines changed

12 files changed

+45
-42
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ DB_HOST=localhost
22
DB_PORT=5432
33
DB_NAME=db_name
44
DB_USER=postgres
5-
DB_PASS=postgres
5+
DB_PASS=postgres

migrations/env.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from logging.config import fileConfig
22

3-
from sqlalchemy import engine_from_config
4-
from sqlalchemy import pool
5-
63
from alembic import context
4+
from sqlalchemy import engine_from_config, pool
75

8-
from pysatl_knowledge.core.config import settings
96
from pysatl_knowledge import models # noqa
7+
from pysatl_knowledge.core.config import settings
108
from pysatl_knowledge.models.base import Base
119

10+
1211
# this is the Alembic Config object, which provides
1312
# access to the values within the .ini file in use.
1413
config = context.config
@@ -71,9 +70,7 @@ def run_migrations_online() -> None:
7170
)
7271

7372
with connectable.connect() as connection:
74-
context.configure(
75-
connection=connection, target_metadata=target_metadata
76-
)
73+
context.configure(connection=connection, target_metadata=target_metadata)
7774

7875
with context.begin_transaction():
7976
context.run_migrations()

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
]
88
license = {text = "MIT"}
99
readme = "README.md"
10-
requires-python = ">=3.9,<3.13"
10+
requires-python = ">=3.10,<3.13"
1111
dependencies = [
1212
"fastapi>=0.111.0",
1313
"uvicorn[standard]>=0.30.0",
@@ -63,6 +63,9 @@ skip_glob = ["**/.env*", "**/env/*", "**/.venv/*", "**/docs/*", "**/user_data/*"
6363
[tool.ruff]
6464
line-length = 100
6565
extend-exclude = [".env", ".venv"]
66+
exclude = [
67+
"migrations/versions",
68+
]
6669

6770
[tool.ruff.lint]
6871
extend-select = [

pysatl_knowledge/core/config.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import os.path
2-
3-
from dotenv import load_dotenv
41
from pydantic_settings import BaseSettings, SettingsConfigDict
52

6-
load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), '../../.env'))
7-
83

94
class Settings(BaseSettings):
105
DB_HOST: str
@@ -15,7 +10,14 @@ class Settings(BaseSettings):
1510

1611
@property
1712
def DATABASE_URL(self) -> str:
18-
return f"postgresql+asyncpg://{self.DB_USER}:{self.DB_PASS}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
13+
return (
14+
f"postgresql+asyncpg://"
15+
f"{self.DB_USER}:"
16+
f"{self.DB_PASS}@"
17+
f"{self.DB_HOST}:"
18+
f"{self.DB_PORT}/"
19+
f"{self.DB_NAME}"
20+
)
1921

2022
model_config = SettingsConfigDict(env_file=".env")
2123

pysatl_knowledge/core/database.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
from requests import session
2-
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
1+
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
32
from sqlalchemy.orm import sessionmaker
43

54
from pysatl_knowledge.core.config import settings
65

6+
77
engine = create_async_engine(
88
url=settings.DATABASE_URL,
99
echo=True,
1010
)
1111

12-
async_session = sessionmaker(
13-
bind=engine,
14-
class_=AsyncSession,
12+
async_session = sessionmaker( # type: ignore
13+
engine,
1514
expire_on_commit=False,
15+
class_=AsyncSession,
1616
)
1717

1818

1919
async def get_session():
20-
async with AsyncSession() as s:
21-
yield s
20+
async with async_session() as session:
21+
yield session
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .user import User
2-
from .experiment import Experiment
1+
from .experiment import Experiment # noqa: F401
2+
from .user import User # noqa: F401

pysatl_knowledge/models/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from sqlalchemy.orm import DeclarativeBase
22

3+
34
class Base(DeclarativeBase):
4-
pass
5+
pass

pysatl_knowledge/models/experiment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Experiment(Base):
88
"""ORM model for experiments in the knowledge base."""
99

10-
__tablename__ = 'experiments'
10+
__tablename__ = "experiments"
1111

1212
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
1313
criterion_code: Mapped[str]

pysatl_knowledge/models/user.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from sqlalchemy.orm import Mapped, mapped_column
2+
23
from pysatl_knowledge.models.base import Base
34

45

56
class User(Base):
67
"""ORM model for users in the knowledge base."""
78

8-
__tablename__ = 'users'
9+
__tablename__ = "users"
910

1011
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
1112
username: Mapped[str] = mapped_column(unique=True, nullable=False)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .user_repository import UserRepository
2-
from .experiment_repository import ExperimentRepository
1+
from .experiment_repository import ExperimentRepository # noqa: F401
2+
from .user_repository import UserRepository # noqa: F401

0 commit comments

Comments
 (0)