Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
rev: v0.16.10
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.1.0
rev: v2.4.0
hooks:
- id: mypy
additional_dependencies:
Expand Down
10 changes: 5 additions & 5 deletions src/sqlacodegen/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def _add_dialect_kwargs_and_info(

dialect_keys: list[str]
try:
dialect_keys = sorted(getattr(obj, "dialect_kwargs"))
dialect_keys = sorted(obj.dialect_kwargs)
except Exception:
return

Expand All @@ -816,9 +816,9 @@ def _add_dialect_kwargs_and_info(
# - dict context (values_for_dict=True): pass raw primitives / str;
# custom objects become str(value) so pformat quotes them.
if values_for_dict:
if isinstance(value, type(None) | bool | int | float):
target_kwargs[key] = value
elif isinstance(value, str | dict | list):
if isinstance(value, type(None) | bool | int | float) or isinstance(
value, str | dict | list
):
target_kwargs[key] = value
else:
target_kwargs[key] = str(value)
Expand Down Expand Up @@ -1153,7 +1153,7 @@ def generate_models(self) -> list[Model]:

# Pick association tables from the metadata into their own set, don't process
# them normally
links: defaultdict[str, list[Model]] = defaultdict(lambda: [])
links: defaultdict[str, list[Model]] = defaultdict(list)
link_tables: set[Table] = set()
for table in self.metadata.sorted_tables:
qualified_name = qualified_table_name(table)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_generator_declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ class TestDomainJson(Base):
)
def test_domain_non_default_json(
generator: CodeGenerator,
domain_type: type[JSON] | type[JSONB],
domain_type: type[JSON | JSONB],
) -> None:
Table(
"test_domain_json",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_generator_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,8 +1254,8 @@ def test_identity_column_decimal_values(generator: CodeGenerator) -> None:
# values instead of integers. This test ensures those are serialized correctly.
identity = Identity(start=1, increment=2)
# Simulate database reflection returning Decimal values (as MSSQL does)
identity.start = Decimal("1") # type: ignore[assignment]
identity.increment = Decimal("2") # type: ignore[assignment]
identity.start = Decimal(1) # type: ignore[assignment]
identity.increment = Decimal(2) # type: ignore[assignment]
Table(
"simple_items",
generator.metadata,
Expand Down
Loading