Skip to content

Commit b1b7942

Browse files
committed
fix: address pre-commit issues (mypy, markdownlint, ruff formatting)
Signed-off-by: Sébastien Han <seb@redhat.com>
1 parent 2ce7ed5 commit b1b7942

5 files changed

Lines changed: 29 additions & 17 deletions

File tree

docs/superpowers/specs/2026-05-18-alembic-migrations-design.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Add `alembic>=1.16` to `pyproject.toml` dependencies.
9696

9797
### 2. Migration Directory Structure
9898

99-
```
99+
```text
100100
src/ogx/core/storage/
101101
schema.py # Canonical schema definitions (single source of truth)
102102
migrations/
@@ -186,7 +186,7 @@ New file: `src/ogx/cli/db.py`
186186

187187
Implements the `Db` top-level subcommand group using the existing `argparse`-based `Subcommand` pattern:
188188

189-
```
189+
```bash
190190
ogx db upgrade [config_path] # Run pending migrations
191191
ogx db current [config_path] # Show current schema revision
192192
ogx db history # Show migration history
@@ -217,7 +217,7 @@ In `lifespan()` in `src/ogx/core/server/server.py` (the async context manager, n
217217
d. If it doesn't exist: this is either a fresh DB (OK, `create_table()` will handle it) or a pre-migration DB (needs `ogx db upgrade`)
218218
2. If the revision is behind: log an error and raise `SystemExit(1)`
219219

220-
```
220+
```text
221221
FATAL: Database schema on backend 'sql_default' is at revision 'abc123', expected 'def456'.
222222
Run 'ogx db upgrade <config.yaml>' before starting the server.
223223
```
@@ -334,7 +334,7 @@ When you need to change the schema of a stable table:
334334

335335
### Architecture
336336

337-
```
337+
```text
338338
ogx db upgrade <config.yaml>
339339
|
340340
v

src/ogx/core/storage/migrations/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
def get_url() -> str:
18-
url = context.config.get_main_option("sqlalchemy.url")
18+
url: str | None = context.config.get_main_option("sqlalchemy.url")
1919
if not url:
2020
raise RuntimeError("sqlalchemy.url must be set in Alembic config")
2121
return url

src/ogx/core/storage/migrations/versions/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
#
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
6-

tests/integration/providers/utils/sqlstore/test_migrations.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,26 @@ def test_adds_backfill_columns(self, pg_engine, pg_url):
119119
conn.execute(sa.text("DROP TABLE IF EXISTS alembic_version CASCADE"))
120120
conn.execute(sa.text("DROP TABLE IF EXISTS conversation_items CASCADE"))
121121
conn.execute(sa.text("DROP TABLE IF EXISTS openai_responses CASCADE"))
122-
conn.execute(sa.text("""
122+
conn.execute(
123+
sa.text("""
123124
CREATE TABLE conversation_items (
124125
id TEXT PRIMARY KEY,
125126
conversation_id TEXT,
126127
created_at INTEGER,
127128
item_data TEXT
128129
)
129-
"""))
130-
conn.execute(sa.text("""
130+
""")
131+
)
132+
conn.execute(
133+
sa.text("""
131134
CREATE TABLE openai_responses (
132135
id TEXT PRIMARY KEY,
133136
created_at INTEGER,
134137
response_object TEXT,
135138
model TEXT
136139
)
137-
"""))
140+
""")
141+
)
138142

139143
cfg = _alembic_cfg(pg_url)
140144
command.upgrade(cfg, "head")
@@ -181,14 +185,16 @@ def test_custom_responses_table_gets_backfills(self, pg_engine, pg_url):
181185
with pg_engine.begin() as conn:
182186
conn.execute(sa.text("DROP TABLE IF EXISTS alembic_version CASCADE"))
183187
conn.execute(sa.text(f'DROP TABLE IF EXISTS "{custom_table}" CASCADE'))
184-
conn.execute(sa.text(f"""
188+
conn.execute(
189+
sa.text(f"""
185190
CREATE TABLE "{custom_table}" (
186191
id TEXT PRIMARY KEY,
187192
created_at INTEGER,
188193
response_object TEXT,
189194
model TEXT
190195
)
191-
"""))
196+
""")
197+
)
192198

193199
cfg = _alembic_cfg(pg_url, x_responses_table=custom_table)
194200
command.upgrade(cfg, "head")
@@ -208,18 +214,22 @@ def test_default_table_untouched_when_custom_name_set(self, pg_engine, pg_url):
208214
conn.execute(sa.text("DROP TABLE IF EXISTS alembic_version CASCADE"))
209215
conn.execute(sa.text("DROP TABLE IF EXISTS openai_responses CASCADE"))
210216
conn.execute(sa.text(f'DROP TABLE IF EXISTS "{custom_table}" CASCADE'))
211-
conn.execute(sa.text("""
217+
conn.execute(
218+
sa.text("""
212219
CREATE TABLE openai_responses (
213220
id TEXT PRIMARY KEY,
214221
model TEXT
215222
)
216-
"""))
217-
conn.execute(sa.text(f"""
223+
""")
224+
)
225+
conn.execute(
226+
sa.text(f"""
218227
CREATE TABLE "{custom_table}" (
219228
id TEXT PRIMARY KEY,
220229
model TEXT
221230
)
222-
"""))
231+
""")
232+
)
223233

224234
cfg = _alembic_cfg(pg_url, x_responses_table=custom_table)
225235
command.upgrade(cfg, "head")

tests/unit/server/test_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ async def fake_check(config: object) -> None:
340340
patch("ogx.core.server.server.Stack", FakeStack),
341341
patch("ogx.core.server.server._check_postgres_schema_versions", side_effect=fake_check),
342342
patch("ogx.core.server.server.concurrent.futures.ThreadPoolExecutor", _ImmediateExecutor),
343-
patch("ogx.core.storage.sqlstore.sqlstore.reset_sqlstore_engines", side_effect=lambda: call_order.append("reset")),
343+
patch(
344+
"ogx.core.storage.sqlstore.sqlstore.reset_sqlstore_engines",
345+
side_effect=lambda: call_order.append("reset"),
346+
),
344347
):
345348
StackApp(config=Mock())
346349

0 commit comments

Comments
 (0)