|
1 | 1 | """Parser: SQLAlchemy declarative model schema → SchemaForge IR.""" |
| 2 | + |
2 | 3 | from __future__ import annotations |
3 | 4 |
|
4 | 5 | import contextlib |
@@ -90,8 +91,12 @@ class Product(DeclarativeBase): |
90 | 91 | model_name = model_m.group(1) |
91 | 92 | base_name = model_m.group(2) |
92 | 93 | # Skip base class definitions themselves |
93 | | - if base_name.lower() in ("declarative_base", "declarativebase", |
94 | | - "as_declarative", "registry"): |
| 94 | + if base_name.lower() in ( |
| 95 | + "declarative_base", |
| 96 | + "declarativebase", |
| 97 | + "as_declarative", |
| 98 | + "registry", |
| 99 | + ): |
95 | 100 | i += 1 |
96 | 101 | continue |
97 | 102 | # Check if any base looks like a declarative base |
@@ -187,7 +192,7 @@ def _parse_model(self, name: str, body: str) -> Table | None: |
187 | 192 | if paren_depth == 0: |
188 | 193 | args_end = args_start + j |
189 | 194 | break |
190 | | - col_args = stripped[args_start + 1:args_end] |
| 195 | + col_args = stripped[args_start + 1 : args_end] |
191 | 196 |
|
192 | 197 | # Parse the Column contents |
193 | 198 | col = self._parse_column(col_name, col_args) |
@@ -338,8 +343,9 @@ def _parse_kwargs(self, args: list[str]) -> dict[str, str]: |
338 | 343 | value = kv_match.group(2).strip() |
339 | 344 |
|
340 | 345 | # Strip quotes from string values |
341 | | - if (value.startswith('"') and value.endswith('"')) or \ |
342 | | - (value.startswith("'") and value.endswith("'")): |
| 346 | + if (value.startswith('"') and value.endswith('"')) or ( |
| 347 | + value.startswith("'") and value.endswith("'") |
| 348 | + ): |
343 | 349 | kwargs[key] = value[1:-1] |
344 | 350 | elif value.lower() in ("true", "false"): |
345 | 351 | kwargs[key] = value.lower() |
|
0 commit comments