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: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ lint-pylint: ## Runs linting with pylint
lint-ruff: ## Runs linting with ruff
poetry run ruff check sanctumlabs_dbkit

.PHONY: lint-ty
lint-ty: ## Runs type checking with ty
poetry run ty check

Comment on lines +69 to +72

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Wire lint-ty into the enforced lint workflow.

This target is currently opt-in: make lint omits it, and the supplied .github/workflows/lint.yml and .gitlab-ci.yml jobs do not invoke it. Add lint-ty to the aggregate target and add it to CI; otherwise the new type checker will not gate changes.

Proposed Makefile change
-lint: format-black lint-flake8 lint-mypy lint-pylint
+lint: format-black lint-flake8 lint-mypy lint-pylint lint-ty
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 69 - 72, Update the aggregate lint target to depend on
lint-ty, and add the lint-ty invocation to the relevant jobs in
.github/workflows/lint.yml and .gitlab-ci.yml so type checking runs in both
local and CI lint workflows.

.PHONY: lint
lint: format-black lint-flake8 lint-mypy lint-pylint

Expand Down
32 changes: 30 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ autoflake = "^2.3.1"
types-sqlalchemy-utils = "^1.0.1"
psycopg2-binary = "^2.9.9"
ruff = ">=0.5.0,<0.16.0"
ty = "^0.0.59"

[tool.mypy]
disallow_incomplete_defs = true
Expand Down
15 changes: 13 additions & 2 deletions sanctumlabs_dbkit/sql/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from typing import List, cast

from sanctumlabs_dbkit.sql.session import Session
from sanctumlabs_dbkit.sql.types import CommitCallback
from sanctumlabs_dbkit.sql.session import Session, AsyncSession
from sanctumlabs_dbkit.sql.types import CommitCallback, CommitCallbackAsync


def on_commit(current_session: Session, callback: CommitCallback) -> None:
Expand All @@ -14,3 +14,14 @@ def on_commit(current_session: Session, callback: CommitCallback) -> None:
List[CommitCallback], current_session.info.setdefault("on_commit_hooks", [])
)
commit_hooks.append(callback)


def on_commit_async(
current_session: AsyncSession, callback: CommitCallbackAsync
) -> None:
"""Sets an async commit callback to the current session"""
commit_hooks = cast(
List[CommitCallbackAsync],
current_session.info.setdefault("on_commit_hooks", []),
)
commit_hooks.append(callback)
4 changes: 2 additions & 2 deletions sanctumlabs_dbkit/sql/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class TableNameMixin:
Mixin that creates the table names of a database
"""

@declared_attr # type: ignore[arg-type]
@declared_attr.directive # type: ignore[arg-type]
def __tablename__(self) -> str:
"""Table names are snake case plural, for example shipping_records"""
return inflection.pluralize(inflection.underscore(self.__name__)) # type: ignore[attr-defined]
return inflection.pluralize(inflection.underscore(self.__name__)) # type: ignore[attr-defined] # ty:ignore[unresolved-attribute]


class BigIntIdentityMixin:
Expand Down
131 changes: 0 additions & 131 deletions sanctumlabs_dbkit/sql/repository.py

This file was deleted.

25 changes: 25 additions & 0 deletions sanctumlabs_dbkit/sql/repository/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Repository package exposing sync and async repository implementations."""

from sanctumlabs_dbkit.sql.repository.repository import (
Repository,
BaseRepository,
WriteRepository,
ReadRepository,
)
from sanctumlabs_dbkit.sql.repository.async_repository import (
AsyncRepository,
AsyncBaseRepository,
AsyncWriteRepository,
AsyncReadRepository,
)

__all__ = [
"Repository",
"BaseRepository",
"WriteRepository",
"ReadRepository",
"AsyncRepository",
"AsyncBaseRepository",
"AsyncWriteRepository",
"AsyncReadRepository",
]
Loading
Loading