Conversation
Without needing to call "select" beforehand.
Without needing to call "select" beforehand.
There was a problem hiding this comment.
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 (
makeadded;resolve/callupdated) 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 (
respository→repository), improved runtime error messaging, added a newto_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.
| error_counter = 0 | ||
| valid_errors: list[Any] = [] | ||
| length = len(args) | ||
|
|
||
| for error in errors: |
Code Coverage OverviewLanguages: Python Python / code-coverage/pytestThe overall coverage in commit 47fe8bf in the Show a code coverage summary of the most impacted files.
Updated |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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_sideshould point at the remote primary key (e.g.,id), otherwise mapper configuration / joins can be incorrect. Alsoparent_idis nullable but typed asMapped[int], which is inconsistent withnullable=True.
parent_id: Mapped[int] = mapped_column(ForeignKey("bars.id"), nullable=True)
parent: Mapped["BarModel"] = relationship(
remote_side=[parent_id],
back_populates="children",
)
| 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) |
| @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. | ||
| """ | ||
|
|
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:
*args,**kwargs) through the container'smake,resolve, andcallmethods, and ensured these are propagated through all relevant internal methods for more flexible dependency resolution. [1] [2] [3] [4] [5] [6] [7]ContainerInterfaceand related contracts to include signatures for the newmakemethod and to remove placeholderpassstatements, clarifying expected behaviors. [1] [2] [3] [4] [5] [6] [7]params.pyfor consistency with the updated container API.Interface and Import Corrections:
respository→repository) in contracts and providers, and re-ordered imports for clarity and to avoid circular dependencies. [1] [2] [3] [4] [5]pyrannic/__init__.pyto bump the version to0.5.7and clean up import ordering.Workflow and CI Improvements:
.github/workflows/tests.ymlby changingreport-typetoreport_typeand addedfail-on-error: falseto prevent CI failures on Codecov upload errors. [1] [2]General Refactoring:
Database Contracts:
pyrannic/contracts/database/__init__.pyfor consistency.passstatements in abstract methods of database connector contracts. [1] [2]