Skip to content

Commit c9142d9

Browse files
author
Revenue Holdings
committed
fix: ruff lint - datetime.UTC, X|None, E501, B904, F821
1 parent 52e58ed commit c9142d9

22 files changed

Lines changed: 145 additions & 106 deletions

‎.github/dependabot.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: pip
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 5
8+
- package-ecosystem: github-actions
9+
directory: "/"
10+
schedule:
11+
interval: weekly
12+
open-pull-requests-limit: 3

‎.github/workflows/publish.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
python -m pip install --upgrade pip
2525
pip install build twine
2626
27+
- name: Lint with ruff
28+
run: pip install ruff && ruff check src/ --target-version py310
29+
2730
- name: Build package
2831
run: |
2932
python -m build

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ Thumbs.db
7070
# Project specific
7171
research/
7272
fixtures/generated/
73+
.ruff_cache/

‎fixtures/sample.alembic.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Initial schema
22
33
Revision ID: sample
4-
Revises:
4+
Revises:
55
Create Date: 2026-05-15 03:00:00.000000
66
"""
7-
from alembic import op
87
import sqlalchemy as sa
8+
from alembic import op
99

1010
# revision identifiers, used by Alembic.
1111
revision = 'sample'
@@ -18,7 +18,7 @@ def upgrade() -> None:
1818
sa.Column('name', sa.String(100), nullable=False),
1919
sa.Column('email', sa.String(255), nullable=False, unique=True),
2020
sa.Column('role', sa.Enum('admin', 'editor', 'viewer'), nullable=False),
21-
sa.Column('is_active', sa.Boolean(), server_default=true),
21+
sa.Column('is_active', sa.Boolean(), server_default=True),
2222
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
2323
)
2424

‎fixtures/sample.sqlalchemy.py‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
"""SchemaForge Demo: Blog Schema (SQLAlchemy Declarative Models)
2-
Convert to any ORM format with: schemaforge convert --from sqlalchemy --to <format> --input fixtures/sample.sqlalchemy.py
2+
Convert to any ORM format with:
3+
schemaforge convert --from sqlalchemy --to <format> --input fixtures/sample.sqlalchemy.py
34
"""
45

6+
import enum
7+
from sqlalchemy import (
8+
Boolean,
9+
Column,
10+
DateTime,
11+
ForeignKey,
12+
Integer,
13+
Numeric,
14+
String,
15+
Text,
16+
func,
17+
)
518
from sqlalchemy import (
6-
Column, Integer, String, Boolean, DateTime, Text, Float, Numeric,
7-
ForeignKey, Enum as SAEnum, func,
19+
Enum as SAEnum,
820
)
921
from sqlalchemy.orm import declarative_base
10-
import enum
1122

1223
Base = declarative_base()
1324

‎scripts/check_consistency.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""Schema consistency check script for CI/CD pipelines."""
2-
import sys
32
import os
3+
import sys
44

55
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
66

77
from schemaforge.convert import convert_schema
8-
from schemaforge.check import check_directory
98

109

1110
def main():

‎src/schemaforge/cli.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def decorator(func):
2020
from .type_config import TypeConfig
2121

2222
# All supported format names (used for CLI choices and detection)
23-
_FORMATS = ["sql", "prisma", "drizzle", "typeorm", "django", "sqlalchemy", "alembic", "json_schema", "graphql", "ef", "scala"]
23+
_FORMATS = [
24+
"sql", "prisma", "drizzle", "typeorm", "django",
25+
"sqlalchemy", "alembic", "json_schema", "graphql", "ef", "scala",
26+
]
2427

2528

2629
@click.group()

‎src/schemaforge/mcp_server.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424

2525
# All supported formats
26-
_FORMATS = ["sql", "prisma", "drizzle", "typeorm", "django", "sqlalchemy", "alembic", "json_schema", "graphql", "ef", "scala"]
26+
_FORMATS = [
27+
"sql", "prisma", "drizzle", "typeorm", "django",
28+
"sqlalchemy", "alembic", "json_schema", "graphql", "ef", "scala",
29+
]
2730
_FORMAT_DESCRIPTIONS = {
2831
"sql": "SQL DDL (Data Definition Language)",
2932
"prisma": "Prisma schema",

‎src/schemaforge/parsers/sql_parser.py‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def parse(self, text: str) -> Schema:
3131
if not stmt:
3232
continue
3333
upper = stmt.upper()
34-
if upper.startswith("CREATE TABLE") or upper.startswith("CREATE TEMPORARY TABLE") or upper.startswith("CREATE OR REPLACE TABLE"):
34+
if (
35+
upper.startswith("CREATE TABLE")
36+
or upper.startswith("CREATE TEMPORARY TABLE")
37+
or upper.startswith("CREATE OR REPLACE TABLE")
38+
):
3539
table = self._parse_create_table(stmt)
3640
if table:
3741
schema.tables.append(table)
@@ -196,8 +200,19 @@ def _parse_column_def(self, defn: str) -> Column | None:
196200
"""Parse a column definition."""
197201
# Skip table constraints
198202
upper = defn.upper()
199-
if (any(kw in upper for kw in ["PRIMARY KEY", "FOREIGN KEY", "INDEX", "KEY", "CHECK", "UNIQUE", "CONSTRAINT"])
200-
and (not defn.split()[0].isidentifier() or defn.split()[0].upper() in ("PRIMARY", "FOREIGN", "INDEX", "KEY", "CHECK", "UNIQUE", "CONSTRAINT"))):
203+
if (
204+
any(kw in upper for kw in [
205+
"PRIMARY KEY", "FOREIGN KEY", "INDEX",
206+
"KEY", "CHECK", "UNIQUE", "CONSTRAINT",
207+
])
208+
and (
209+
not defn.split()[0].isidentifier()
210+
or defn.split()[0].upper() in (
211+
"PRIMARY", "FOREIGN", "INDEX",
212+
"KEY", "CHECK", "UNIQUE", "CONSTRAINT",
213+
)
214+
)
215+
):
201216
return None
202217

203218
# Parse: column_name TYPE [(args)] [constraints...]

‎src/schemaforge/parsers/typeorm_parser.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ def _split_entities(self, text: str) -> list[str]:
9191
for line in text.split("\n"):
9292
stripped = line.strip()
9393
# Detect @Entity, @ViewEntity, or bare class extends pattern
94-
if (stripped.startswith("@") or stripped.startswith("export class")) and (stripped.startswith("export class") or "class " in stripped):
94+
if (
95+
(stripped.startswith("@") or stripped.startswith("export class"))
96+
and (stripped.startswith("export class") or "class " in stripped)
97+
):
9598
in_class = True
9699
current = line + "\n"
97100
brace_depth = 0

0 commit comments

Comments
 (0)