Skip to content

Refactor ORM interfaces and enhance dependency resolution features - #4

Merged
AriasBros merged 22 commits into
mainfrom
dev
Jul 26, 2026
Merged

Refactor ORM interfaces and enhance dependency resolution features#4
AriasBros merged 22 commits into
mainfrom
dev

Conversation

@AriasBros

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and fixes across the codebase, focusing on dependency injection enhancements, interface corrections, and workflow configuration updates. The most significant changes are grouped below.

Dependency Injection and Container Improvements:

  • Added support for passing arbitrary positional and keyword arguments (*args, **kwargs) through the container's make, resolve, and call methods, and ensured these are propagated through all relevant internal methods for more flexible dependency resolution. [1] [2] [3] [4] [5] [6] [7]
  • Updated the ContainerInterface and related contracts to include signatures for the new make method and to remove placeholder pass statements, clarifying expected behaviors. [1] [2] [3] [4] [5] [6] [7]
  • Improved dependency wrapping in params.py for consistency with the updated container API.

Interface and Import Corrections:

  • Fixed typos in import paths (e.g., respositoryrepository) in contracts and providers, and re-ordered imports for clarity and to avoid circular dependencies. [1] [2] [3] [4] [5]
  • Updated pyrannic/__init__.py to bump the version to 0.5.7 and clean up import ordering.

Workflow and CI Improvements:

  • Corrected Codecov action configuration in .github/workflows/tests.yml by changing report-type to report_type and added fail-on-error: false to prevent CI failures on Codecov upload errors. [1] [2]

General Refactoring:

  • Cleaned up and standardized imports across several modules for better maintainability. [1] [2]

Database Contracts:

  • Added explicit interface exports in pyrannic/contracts/database/__init__.py for consistency.
  • Removed unnecessary pass statements in abstract methods of database connector contracts. [1] [2]

Copilot AI review requested due to automatic review settings July 26, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors several ORM-related interfaces/classes and enhances the dependency injection container to support forwarding arbitrary *args/**kwargs through resolution pathways, alongside assorted contract cleanup and CI/workflow tweaks.

Changes:

  • Extended the DI container API (make added; resolve/call updated) to accept and propagate *args/**kwargs, with new unit tests covering positional/keyword/mixed resolution.
  • Refactored SQLAlchemy ORM connectors/repositories/schemas (renames, interface alignment, query builder filtering changes) and expanded ORM unit test coverage.
  • Fixed multiple import-path typos (respositoryrepository), improved runtime error messaging, added a new to_kebab_case() helper + tests, and adjusted Codecov workflow inputs.

Reviewed changes

Copilot reviewed 72 out of 74 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/support/string/test_to_kebab_case.py Adds unit coverage for new to_kebab_case() helper.
tests/unit/support/facades/test_config_facade.py Fixes config contract import path typo in tests.
tests/unit/orm/utils.py Removes old ORM test utilities (superseded by new tests).
tests/unit/orm/test_abstract_model.py Removes old abstract model tablename test (replaced by new suite).
tests/unit/orm/sqlalchemy/utils.py Expands SQLAlchemy test models/mixins used across new ORM tests.
tests/unit/orm/sqlalchemy/test_sa_serializable.py Adds serialization (to_dict) behavior tests incl. nested/hybrid.
tests/unit/orm/sqlalchemy/test_sa_schema.py Adds schema create/drop tests for sync and async engines.
tests/unit/orm/sqlalchemy/test_sa_repository.py Adds repository generic model binding test.
tests/unit/orm/sqlalchemy/test_sa_query_builder.py Updates connector usage/imports for async query builder tests.
tests/unit/orm/sqlalchemy/test_sa_model.py Adds model tablename/PK/dirty-state tests.
tests/unit/orm/sqlalchemy/test_sa_inspectionable.py Adds inspection/introspection tests (columns, relations, hybrids).
tests/unit/orm/sqlalchemy/test_sa_connector.py Adds connector disconnect tests for sync/async connectors.
tests/unit/orm/sqlalchemy/mixins/test_sa_soft_deletes.py Adds SoftDeletes mixin unit tests.
tests/unit/orm/sqlalchemy/mixins/test_sa_has_timestamps.py Adds HasTimestamps mixin unit tests.
tests/unit/orm/sqlalchemy/mixins/test_sa_has_timestamp.py Adds HasTimestamp mixin unit tests.
tests/unit/orm/sqlalchemy/conftest.py Adds async fixture wiring repository/connector/manager for ORM tests.
tests/unit/orm/abstract_model/test_tablename_abstract_model.py Adds broader AbstractModel.tablename() test coverage (suffixes/intermediate tables).
tests/unit/http/resources/utils.py Removes debug printing from resource relationship serialization test helper.
tests/unit/http/resources/test_collection.py Tightens assertions around improved required-meta exception message.
tests/unit/http/providers/application/app/http/routers/heroes.py Removes debug printing; import reorder.
tests/unit/http/providers/application/app/http/middlewares/middleware_b.py Removes debug printing in middleware.
tests/unit/http/providers/application/app/http/middlewares/middleware_a.py Removes debug printing in middleware.
tests/unit/http/providers/application_no_providers/app/http/routers/heroes.py Removes debug printing; import reorder.
tests/unit/http/providers/application_no_providers/app/http/middlewares/b_middleware.py Removes debug printing in middleware.
tests/unit/http/providers/application_no_providers/app/http/middlewares/a_middleware.py Removes debug printing in middleware.
tests/unit/database/test_database_provider.py Updates assertions/imports to new connector class name.
tests/unit/container/container/test_resolve.py Adds tests for generics + positional/keyword/mixed arg resolve.
tests/unit/container/container/test_make.py Adds tests for new make() API and its arg forwarding.
tests/unit/container/conftest.py Adds generic + paramized services for container tests; minor signature cleanup.
tests/unit/config/repository/test_integer.py Fixes config contract import path typo.
tests/unit/config/repository/test_float.py Fixes config contract import path typo.
tests/unit/config/repository/test_config_repository_set_method.py Fixes config contract import path typo.
tests/unit/config/repository/test_config_repository_has_method.py Fixes config contract import path typo.
tests/unit/config/repository/test_config_repository_get_method.py Fixes config contract import path typo.
tests/unit/config/repository/test_config_repository_all_method.py Fixes config contract import path typo.
tests/unit/config/repository/test_boolean.py Fixes config contract import path typo.
tests/unit/config/repository/conftest.py Fixes config contract import path typo in fixture setup.
tests/unit/config/provider/test_provider.py Fixes config contract import path typo.
tests/unit/bootstrap/manager/test_start_critical_services.py Fixes config contract import path typo.
tests/unit/bootstrap/manager/test_lifespan_method.py Fixes config contract import path typo; import reorder.
tests/unit/bootstrap/manager/providers.py Fixes config contract import path typo.
tests/conftest.py Switches to exporting ApplicationInterface from pyrannic.contracts package.
tests/application/app/http/routers/heroes.py Removes debug printing from example router.
tests/application/app/http/middlewares/middleware_b.py Removes debug printing in middleware.
tests/application/app/http/middlewares/middleware_a.py Removes debug printing in middleware.
pyrannic/support/string.py Adds to_kebab_case() helper.
pyrannic/support/facades/config.py Fixes config contract import path typo.
pyrannic/orm/sqlalchemy/serializable.py Removes debug try/except printing from to_dict() field access.
pyrannic/orm/sqlalchemy/schema.py Tightens type hints for schema create/drop and updates docstrings.
pyrannic/orm/sqlalchemy/repository.py Ensures query preparation occurs before all().
pyrannic/orm/sqlalchemy/connector.py Renames connector classes; adds application dependency; updates alembic script path and engine options comments.
pyrannic/orm/sqlalchemy/async_repository.py Renames async repository interface usage; prepares query before all().
pyrannic/orm/sqlalchemy/abstract_query_builder.py Refactors filter() to support either expressions or kwargs with overloads.
pyrannic/orm/sqlalchemy/init.py Re-exports renamed connectors/schema and normalizes export ordering.
pyrannic/orm/abstract_model.py Enhances tablename() generation + adds intermediate table handling hook.
pyrannic/orm/init.py Exposes AbstractModel at package level.
pyrannic/http/resources/collection.py Improves required-meta exception message with class-specific guidance.
pyrannic/database/provider.py Updates provider to bind new connector class name.
pyrannic/contracts/orm/query_builder.py Updates query builder contract to overload filter() (kwargs vs expressions).
pyrannic/contracts/orm/async_repository.py Renames async repository interface type to AsyncRepositoryInterface.
pyrannic/contracts/orm/init.py Adds ORM contract re-export.
pyrannic/contracts/database/connector.py Removes placeholder pass statements from abstract methods.
pyrannic/contracts/database/init.py Adds database contract re-exports.
pyrannic/contracts/container/container.py Adds make() contract + arg forwarding to resolve() signature; removes pass placeholders.
pyrannic/contracts/container/init.py Adds container contract re-exports.
pyrannic/contracts/config/repository.py Adds new config repository interface module under corrected path.
pyrannic/contracts/init.py Re-exports updated contracts (config/container/orm) and fixes path typo.
pyrannic/container/params.py Updates dependency wrapper to pass request by keyword (new resolve signature).
pyrannic/container/container.py Implements make() and arg forwarding through resolution/call chain.
pyrannic/config/repository.py Fixes config contract import path typo.
pyrannic/config/provider.py Fixes config contract import path typo.
pyrannic/init.py Bumps version to 0.5.7 and cleans up import ordering/exports.
.gitignore Ignores typings directory.
.github/workflows/tests.yml Fixes Codecov input name (report_type) and avoids failing CI on upload errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +494 to 498
error_counter = 0
valid_errors: list[Any] = []
length = len(args)

for error in errors:
Comment thread pyrannic/contracts/container/container.py
Comment thread tests/unit/orm/sqlalchemy/utils.py Outdated
Copilot AI review requested due to automatic review settings July 26, 2026 21:46
@github-code-quality

github-code-quality Bot commented Jul 26, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Python

Python / code-coverage/pytest

The overall coverage in commit 47fe8bf in the dev branch is 88%. The coverage in commit 92c844e in the main branch is 86%.

Show a code coverage summary of the most impacted files.
File main 92c844e dev 47fe8bf +/-
orm/sqlalchemy/...uery_builder.py 45% 45% 0%
bootstrap/manager.py 100% 100% 0%
container/container.py 100% 100% 0%
database/migration.py 100% 100% 0%
http/exceptions/exception.py 100% 100% 0%
orm/sqlalchemy/connector.py 99% 100% +1%
orm/sqlalchemy/...soft_deletes.py 82% 95% +13%
orm/sqlalchemy/...s_timestamps.py 77% 100% +23%
orm/sqlalchemy/...spectionable.py 68% 100% +32%
orm/sqlalchemy/serializable.py 22% 100% +78%

Updated July 26, 2026 21:53 UTC

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tests/unit/orm/sqlalchemy/utils.py:17

  • Self-referential relationship is configured with remote_side=[parent_id] (the FK column). For SQLAlchemy self-references, remote_side should point at the remote primary key (e.g., id), otherwise mapper configuration / joins can be incorrect. Also parent_id is nullable but typed as Mapped[int], which is inconsistent with nullable=True.
    parent_id: Mapped[int] = mapped_column(ForeignKey("bars.id"), nullable=True)
    parent: Mapped["BarModel"] = relationship(
        remote_side=[parent_id],
        back_populates="children",
    )

Copilot AI review requested due to automatic review settings July 26, 2026 21:52
@AriasBros
AriasBros merged commit 82d8151 into main Jul 26, 2026
9 checks passed
@AriasBros
AriasBros deleted the dev branch July 26, 2026 21:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.

class BarModel(Model):
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(255))
parent_id: Mapped[int] = mapped_column(ForeignKey("bars.id"), nullable=True)
Comment on lines 146 to 154
@overload
def filter(self, **kwargs: Any) -> Self:
self._prepare_query()

if isinstance(self._query, (Select, Delete)):
self._query = self._query.filter_by(**kwargs)
"""
Apply filtering conditions to the query using keyword arguments.

return self
:param kwargs: Column-value pairs for filtering.
:return: The current instance of the query builder.
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants