diff --git a/advanced_alchemy/base.py b/advanced_alchemy/base.py index 6e61dcb4..526aca13 100644 --- a/advanced_alchemy/base.py +++ b/advanced_alchemy/base.py @@ -19,6 +19,7 @@ orm_insert_sentinel, registry, ) +from sqlalchemy.orm.decl_base import _TableArgsType as TableArgsType # pyright: ignore[reportPrivateUsage] from advanced_alchemy.types import GUID, UUID_UTILS_INSTALLED, BigIntIdentity, DateTimeUTC, JsonB @@ -32,7 +33,6 @@ uuid7 = uuid4 # type: ignore[assignment] if TYPE_CHECKING: - from sqlalchemy.orm.decl_base import _TableArgsType as TableArgsType # pyright: ignore[reportPrivateUsage] from sqlalchemy.sql import FromClause from sqlalchemy.sql.schema import ( _NamingSchemaParameter as NamingSchemaParameter, # pyright: ignore[reportPrivateUsage] @@ -61,6 +61,7 @@ "SQLQuery", "orm_registry", "merge_table_arguments", + "TableArgsType", ) @@ -81,7 +82,6 @@ """Regular expression for table name""" - def merge_table_arguments(cls: type[DeclarativeBase], table_args: TableArgsType | None = None) -> TableArgsType: """Merge Table Arguments. @@ -91,7 +91,7 @@ def merge_table_arguments(cls: type[DeclarativeBase], table_args: TableArgsType Args: cls (DeclarativeBase): This is the model that will get the table args - table_args: additional information to add to tableargs + table_args: additional information to add to table_args Returns: tuple | dict: The merged __table_args__ property @@ -99,7 +99,7 @@ def merge_table_arguments(cls: type[DeclarativeBase], table_args: TableArgsType args: list[Any] = [] kwargs: dict[str, Any] = {} - mixin_table_args = (getattr(super(base_cls, cls), "__table_args__", None) for base_cls in cls.__bases__) + mixin_table_args = (getattr(super(base_cls, cls), "__table_args__", None) for base_cls in cls.__bases__) # pyright: ignore[reportUnknownParameter,reportUnknownArgumentType,reportArgumentType] for arg_to_merge in (*mixin_table_args, table_args): if arg_to_merge: diff --git a/advanced_alchemy/repository/__init__.py b/advanced_alchemy/repository/__init__.py index a77d7523..63909287 100644 --- a/advanced_alchemy/repository/__init__.py +++ b/advanced_alchemy/repository/__init__.py @@ -8,7 +8,7 @@ SQLAlchemySyncRepository, SQLAlchemySyncSlugRepository, ) -from advanced_alchemy.repository._util import get_instrumented_attr, model_from_dict +from advanced_alchemy.repository._util import LoadSpec, get_instrumented_attr, model_from_dict __all__ = ( "SQLAlchemyAsyncRepository", @@ -19,4 +19,5 @@ "SQLAlchemySyncQueryRepository", "get_instrumented_attr", "model_from_dict", + "LoadSpec", ) diff --git a/advanced_alchemy/service/_converters.py b/advanced_alchemy/service/_converters.py index efaddf9a..d991d389 100644 --- a/advanced_alchemy/service/_converters.py +++ b/advanced_alchemy/service/_converters.py @@ -12,6 +12,7 @@ ) from uuid import UUID +from advanced_alchemy.exceptions import AdvancedAlchemyError from advanced_alchemy.filters import FilterTypes, LimitOffset from advanced_alchemy.repository.typing import ModelOrRowMappingT from advanced_alchemy.service.pagination import OffsetPagination @@ -34,20 +35,17 @@ def convert(*args: Any, **kwargs: Any) -> Any: # type: ignore[no-redef] # noqa: try: - from pydantic.main import ModelMetaclass # pyright: ignore[reportAssignmentType] + from pydantic import BaseModel # pyright: ignore[reportAssignmentType] from pydantic.type_adapter import TypeAdapter # pyright: ignore[reportAssignmentType] except ImportError: # pragma: nocover - class ModelMetaclass: # type: ignore[no-redef] + class BaseModel: # type: ignore[no-redef] """Placeholder Implementation""" class TypeAdapter: # type: ignore[no-redef] """Placeholder Implementation""" -EMPTY_FILTER: list[FilterTypes] = [] - - def _default_deserializer( target_type: Any, value: Any, @@ -101,10 +99,24 @@ def _find_filter( def to_schema( data: ModelOrRowMappingT | Sequence[ModelOrRowMappingT], total: int | None = None, - filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] = EMPTY_FILTER, + filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] | None = None, schema_type: type[ModelDTOT] | None = None, ) -> ModelOrRowMappingT | OffsetPagination[ModelOrRowMappingT] | ModelDTOT | OffsetPagination[ModelDTOT]: - if schema_type is not None and issubclass(schema_type, Struct): + if filters is None: + filters = [] + if schema_type is None: + if not issubclass(type(data), Sequence): + return cast("ModelOrRowMappingT", data) + limit_offset = _find_filter(LimitOffset, filters=filters) + total = total or len(data) # type: ignore[arg-type] + limit_offset = limit_offset if limit_offset is not None else LimitOffset(limit=len(data), offset=0) # type: ignore[arg-type] + return OffsetPagination[ModelOrRowMappingT]( + items=cast("List[ModelOrRowMappingT]", data), + limit=limit_offset.limit, + offset=limit_offset.offset, + total=total, + ) + if issubclass(schema_type, Struct): if not isinstance(data, Sequence): return convert( # type: ignore # noqa: PGH003 obj=data, @@ -137,9 +149,9 @@ def to_schema( total=total, ) - if schema_type is not None and issubclass(schema_type, ModelMetaclass): + if issubclass(schema_type, BaseModel): if not isinstance(data, Sequence): - return TypeAdapter(schema_type).validate_python(data, from_attributes=True) # pyright: ignore[reportUnknownVariableType,reportUnknownMemberType,reportAttributeAccessIssue,reportCallIssue] + return TypeAdapter(schema_type).validate_python(data, from_attributes=True) # type: ignore[return-value] # pyright: ignore[reportUnknownVariableType,reportUnknownMemberType,reportAttributeAccessIssue,reportCallIssue] limit_offset = _find_filter(LimitOffset, filters=filters) total = total if total else len(data) limit_offset = limit_offset if limit_offset is not None else LimitOffset(limit=len(data), offset=0) @@ -149,14 +161,5 @@ def to_schema( offset=limit_offset.offset, total=total, ) - if not issubclass(type(data), Sequence): - return cast("ModelOrRowMappingT", data) - limit_offset = _find_filter(LimitOffset, filters=filters) - total = total or len(data) # type: ignore[arg-type] - limit_offset = limit_offset if limit_offset is not None else LimitOffset(limit=len(data), offset=0) # type: ignore[arg-type] - return OffsetPagination[ModelOrRowMappingT]( - items=cast("List[ModelOrRowMappingT]", data), - limit=limit_offset.limit, - offset=limit_offset.offset, - total=total, - ) + msg = "`schema_type` should be a valid Pydantic or Msgspec schema" + raise AdvancedAlchemyError(msg) diff --git a/advanced_alchemy/service/_util.py b/advanced_alchemy/service/_util.py index 99a22e55..82d4f145 100644 --- a/advanced_alchemy/service/_util.py +++ b/advanced_alchemy/service/_util.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, overload -from advanced_alchemy.service._converters import EMPTY_FILTER, to_schema +from advanced_alchemy.service._converters import to_schema if TYPE_CHECKING: from collections.abc import Sequence @@ -31,7 +31,7 @@ def to_schema( self, data: ModelOrRowMappingT, total: int | None = None, - filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] = EMPTY_FILTER, + filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] = ..., ) -> ModelOrRowMappingT: ... @overload @@ -39,7 +39,7 @@ def to_schema( self, data: Sequence[ModelOrRowMappingT], total: int | None = None, - filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] = EMPTY_FILTER, + filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] | None = None, ) -> OffsetPagination[ModelOrRowMappingT]: ... @overload @@ -47,8 +47,9 @@ def to_schema( self, data: ModelProtocol | RowMapping, total: int | None = None, - filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] = EMPTY_FILTER, - schema_type: type[ModelDTOT] = ..., + filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] | None = None, + *, + schema_type: type[ModelDTOT], ) -> ModelDTOT: ... @overload @@ -56,15 +57,17 @@ def to_schema( self, data: Sequence[ModelOrRowMappingT], total: int | None = None, - filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] = EMPTY_FILTER, - schema_type: type[ModelDTOT] = ..., + filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] | None = None, + *, + schema_type: type[ModelDTOT], ) -> OffsetPagination[ModelDTOT]: ... def to_schema( self, data: ModelOrRowMappingT | Sequence[ModelOrRowMappingT], total: int | None = None, - filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] = EMPTY_FILTER, + filters: Sequence[FilterTypes | ColumnElement[bool]] | Sequence[FilterTypes] | None = None, + *, schema_type: type[ModelDTOT] | None = None, ) -> ModelOrRowMappingT | OffsetPagination[ModelOrRowMappingT] | ModelDTOT | OffsetPagination[ModelDTOT]: """Convert the object to a response schema. When `schema_type` is None, the model is returned with no conversion. diff --git a/pdm.lock b/pdm.lock index 2d5fd930..5465b515 100644 --- a/pdm.lock +++ b/pdm.lock @@ -930,52 +930,52 @@ files = [ [[package]] name = "duckdb" -version = "0.10.2" +version = "0.10.3" requires_python = ">=3.7.0" summary = "DuckDB in-process database" groups = ["dev"] files = [ - {file = "duckdb-0.10.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3891d3ac03e12a3e5c43afa3020fe701f64060f52d25f429a1ed7b5d914368d3"}, - {file = "duckdb-0.10.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4f63877651f1fb940e049dc53038eb763856616319acf4f892b1c3ed074f5ab0"}, - {file = "duckdb-0.10.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:06e3a36f04f4d98d2c0bbdd63e517cfbe114a795306e26ec855e62e076af5043"}, - {file = "duckdb-0.10.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cf5f95ad5b75c8e65c6508b4df02043dd0b9d97712b9a33236ad77c388ce7861"}, - {file = "duckdb-0.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ff62bc98278c98fecbd6eecec5d698ad41ebd654110feaadbf8ac8bb59b1ecf"}, - {file = "duckdb-0.10.2-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cceede13fde095c23cf9a53adf7c414c7bfb21b9a7aa6a4836014fdbecbfca70"}, - {file = "duckdb-0.10.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:acdfff60b7efccd7f731213a9795851256249dfacf80367074b2b2e144f716dd"}, - {file = "duckdb-0.10.2-cp310-cp310-win_amd64.whl", hash = "sha256:4a5d5655cf0bdaf664a6f332afe465e02b08cef715548a0983bb7aef48da06a6"}, - {file = "duckdb-0.10.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:a9d15842876d18763e085648656cccc7660a215d16254906db5c4471be2c7732"}, - {file = "duckdb-0.10.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c88cdcdc8452c910e4298223e7d9fca291534ff5aa36090aa49c9e6557550b13"}, - {file = "duckdb-0.10.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:364cd6f5dc8a1010d144d08c410ba9a74c521336ee5bda84fabc6616216a6d6a"}, - {file = "duckdb-0.10.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4c57c11d1060296f5e9ebfb5bb7e5521e0d77912e8f9ff43c90240c3311e9de9"}, - {file = "duckdb-0.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:186d86b8dda8e1076170eb770bb2bb73ea88ca907d92885c9695d6515207b205"}, - {file = "duckdb-0.10.2-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5f65b62f31c6bff21afc0261cfe28d238b8f34ec78f339546b12f4740c39552a"}, - {file = "duckdb-0.10.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:a860d7466a5c93714cdd94559ce9e1db2ab91914f0941c25e5e93d4ebe36a5fa"}, - {file = "duckdb-0.10.2-cp311-cp311-win_amd64.whl", hash = "sha256:33308190e9c7f05a3a0a2d46008a043effd4eae77011869d7c18fb37acdd9215"}, - {file = "duckdb-0.10.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:3a8b2f1229b4aecb79cd28ffdb99032b1497f0a805d0da1136a9b6115e1afc70"}, - {file = "duckdb-0.10.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d23a6dea61963733a0f45a0d0bbb1361fb2a47410ed5ff308b4a1f869d4eeb6f"}, - {file = "duckdb-0.10.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:20ee0aa27e688aa52a40b434ec41a50431d0b06edeab88edc2feaca18d82c62c"}, - {file = "duckdb-0.10.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:80a6d43d9044f0997a15a92e0c0ff3afd21151a1e572a92f439cc4f56b7090e1"}, - {file = "duckdb-0.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6934758cacd06029a5c9f54556a43bd277a86757e22bf8d0dd11ca15c1813d1c"}, - {file = "duckdb-0.10.2-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7a11e2d68bd79044eea5486b1cddb5b915115f537e5c74eeb94c768ce30f9f4b"}, - {file = "duckdb-0.10.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0bf58385c43b8e448a2fea7e8729054934bf73ea616d1d7ef8184eda07f975e2"}, - {file = "duckdb-0.10.2-cp312-cp312-win_amd64.whl", hash = "sha256:eae75c7014597ded6e7f6dc51e32d48362a31608acd73e9f795748ee94335a54"}, - {file = "duckdb-0.10.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:c461d6b4619e80170044a9eb999bbf4097e330d3a4974ced0a7eaeb79c7c39f6"}, - {file = "duckdb-0.10.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:909351ff72eb3b50b89761251148d8a186594d8a438e12dcf5494794caff6693"}, - {file = "duckdb-0.10.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:d9eeb8393d69abafd355b869669957eb85b89e4df677e420b9ef0693b7aa6cb4"}, - {file = "duckdb-0.10.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3102bcf5011e8f82ea3c2bde43108774fe5a283a410d292c0843610ea13e2237"}, - {file = "duckdb-0.10.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d64d443613e5f16caf7d67102733538c90f7715867c1a98597efd3babca068e3"}, - {file = "duckdb-0.10.2-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cb31398826d1b7473344e5ee8e0f826370c9752549469ba1327042ace9041f80"}, - {file = "duckdb-0.10.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d09dcec467cd6127d5cc1fb0ce4efbd77e761882d9d772b0f64fc2f79a2a1cde"}, - {file = "duckdb-0.10.2-cp38-cp38-win_amd64.whl", hash = "sha256:82fab1a24faf7c33d8a7afed08b57ee36e8821a3a68a2f1574cd238ea440bba0"}, - {file = "duckdb-0.10.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:38607e6e6618e8ea28c8d9b67aa9e22cfd6d6d673f2e8ab328bd6e867b697f69"}, - {file = "duckdb-0.10.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:fb0c23bc8c09615bff38aebcf8e92e6ae74959c67b3c9e5b00edddc730bf22be"}, - {file = "duckdb-0.10.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:00576c11c78c83830ab483bad968e07cd9b5f730e7ffaf5aa5fadee5ac4f71e9"}, - {file = "duckdb-0.10.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:077db692cdda50c4684ef87dc2a68507665804caa90e539dbe819116bda722ad"}, - {file = "duckdb-0.10.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ca25984ad9f9a04e46e8359f852668c11569534e3bb8424b80be711303ad2314"}, - {file = "duckdb-0.10.2-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6a72cc40982c7b92cf555e574618fc711033b013bf258b611ba18d7654c89d8c"}, - {file = "duckdb-0.10.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d27b9efd6e788eb561535fdc0cbc7c74aca1ff39f748b7cfc27aa49b00e22da1"}, - {file = "duckdb-0.10.2-cp39-cp39-win_amd64.whl", hash = "sha256:4800469489bc262dda61a7f1d40acedf67cf2454874e9d8bbf07920dc2b147e6"}, - {file = "duckdb-0.10.2.tar.gz", hash = "sha256:0f609c9d5f941f1ecde810f010dd9321cd406a552c1df20318a13fa64247f67f"}, + {file = "duckdb-0.10.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:cd25cc8d001c09a19340739ba59d33e12a81ab285b7a6bed37169655e1cefb31"}, + {file = "duckdb-0.10.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2f9259c637b917ca0f4c63887e8d9b35ec248f5d987c886dfc4229d66a791009"}, + {file = "duckdb-0.10.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b48f5f1542f1e4b184e6b4fc188f497be8b9c48127867e7d9a5f4a3e334f88b0"}, + {file = "duckdb-0.10.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e327f7a3951ea154bb56e3fef7da889e790bd9a67ca3c36afc1beb17d3feb6d6"}, + {file = "duckdb-0.10.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d8b20ed67da004b4481973f4254fd79a0e5af957d2382eac8624b5c527ec48c"}, + {file = "duckdb-0.10.3-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d37680b8d7be04e4709db3a66c8b3eb7ceba2a5276574903528632f2b2cc2e60"}, + {file = "duckdb-0.10.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:3d34b86d6a2a6dfe8bb757f90bfe7101a3bd9e3022bf19dbddfa4b32680d26a9"}, + {file = "duckdb-0.10.3-cp310-cp310-win_amd64.whl", hash = "sha256:73b1cb283ca0f6576dc18183fd315b4e487a545667ffebbf50b08eb4e8cdc143"}, + {file = "duckdb-0.10.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:d917dde19fcec8cadcbef1f23946e85dee626ddc133e1e3f6551f15a61a03c61"}, + {file = "duckdb-0.10.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:46757e0cf5f44b4cb820c48a34f339a9ccf83b43d525d44947273a585a4ed822"}, + {file = "duckdb-0.10.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:338c14d8ac53ac4aa9ec03b6f1325ecfe609ceeb72565124d489cb07f8a1e4eb"}, + {file = "duckdb-0.10.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:651fcb429602b79a3cf76b662a39e93e9c3e6650f7018258f4af344c816dab72"}, + {file = "duckdb-0.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3ae3c73b98b6215dab93cc9bc936b94aed55b53c34ba01dec863c5cab9f8e25"}, + {file = "duckdb-0.10.3-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:56429b2cfe70e367fb818c2be19f59ce2f6b080c8382c4d10b4f90ba81f774e9"}, + {file = "duckdb-0.10.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b46c02c2e39e3676b1bb0dc7720b8aa953734de4fd1b762e6d7375fbeb1b63af"}, + {file = "duckdb-0.10.3-cp311-cp311-win_amd64.whl", hash = "sha256:bcd460feef56575af2c2443d7394d405a164c409e9794a4d94cb5fdaa24a0ba4"}, + {file = "duckdb-0.10.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:e229a7c6361afbb0d0ab29b1b398c10921263c52957aefe3ace99b0426fdb91e"}, + {file = "duckdb-0.10.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:732b1d3b6b17bf2f32ea696b9afc9e033493c5a3b783c292ca4b0ee7cc7b0e66"}, + {file = "duckdb-0.10.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f5380d4db11fec5021389fb85d614680dc12757ef7c5881262742250e0b58c75"}, + {file = "duckdb-0.10.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:468a4e0c0b13c55f84972b1110060d1b0f854ffeb5900a178a775259ec1562db"}, + {file = "duckdb-0.10.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fa1e7ff8d18d71defa84e79f5c86aa25d3be80d7cb7bc259a322de6d7cc72da"}, + {file = "duckdb-0.10.3-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ed1063ed97c02e9cf2e7fd1d280de2d1e243d72268330f45344c69c7ce438a01"}, + {file = "duckdb-0.10.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:22f2aad5bb49c007f3bfcd3e81fdedbc16a2ae41f2915fc278724ca494128b0c"}, + {file = "duckdb-0.10.3-cp312-cp312-win_amd64.whl", hash = "sha256:8f9e2bb00a048eb70b73a494bdc868ce7549b342f7ffec88192a78e5a4e164bd"}, + {file = "duckdb-0.10.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:d75d67024fc22c8edfd47747c8550fb3c34fb1cbcbfd567e94939ffd9c9e3ca7"}, + {file = "duckdb-0.10.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f3796e9507c02d0ddbba2e84c994fae131da567ce3d9cbb4cbcd32fadc5fbb26"}, + {file = "duckdb-0.10.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:78e539d85ebd84e3e87ec44d28ad912ca4ca444fe705794e0de9be3dd5550c11"}, + {file = "duckdb-0.10.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7a99b67ac674b4de32073e9bc604b9c2273d399325181ff50b436c6da17bf00a"}, + {file = "duckdb-0.10.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1209a354a763758c4017a1f6a9f9b154a83bed4458287af9f71d84664ddb86b6"}, + {file = "duckdb-0.10.3-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3b735cea64aab39b67c136ab3a571dbf834067f8472ba2f8bf0341bc91bea820"}, + {file = "duckdb-0.10.3-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:816ffb9f758ed98eb02199d9321d592d7a32a6cb6aa31930f4337eb22cfc64e2"}, + {file = "duckdb-0.10.3-cp38-cp38-win_amd64.whl", hash = "sha256:1631184b94c3dc38b13bce4045bf3ae7e1b0ecbfbb8771eb8d751d8ffe1b59b3"}, + {file = "duckdb-0.10.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:fb98c35fc8dd65043bc08a2414dd9f59c680d7e8656295b8969f3f2061f26c52"}, + {file = "duckdb-0.10.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7e75c9f5b6a92b2a6816605c001d30790f6d67ce627a2b848d4d6040686efdf9"}, + {file = "duckdb-0.10.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ae786eddf1c2fd003466e13393b9348a44b6061af6fe7bcb380a64cac24e7df7"}, + {file = "duckdb-0.10.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b9387da7b7973707b0dea2588749660dd5dd724273222680e985a2dd36787668"}, + {file = "duckdb-0.10.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:538f943bf9fa8a3a7c4fafa05f21a69539d2c8a68e557233cbe9d989ae232899"}, + {file = "duckdb-0.10.3-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6930608f35025a73eb94252964f9f19dd68cf2aaa471da3982cf6694866cfa63"}, + {file = "duckdb-0.10.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:03bc54a9cde5490918aad82d7d2a34290e3dfb78d5b889c6626625c0f141272a"}, + {file = "duckdb-0.10.3-cp39-cp39-win_amd64.whl", hash = "sha256:372b6e3901d85108cafe5df03c872dfb6f0dbff66165a0cf46c47246c1957aa0"}, + {file = "duckdb-0.10.3.tar.gz", hash = "sha256:c5bd84a92bc708d3a6adffe1f554b94c6e76c795826daaaf482afc3d9c636971"}, ] [[package]] @@ -2694,7 +2694,7 @@ files = [ [[package]] name = "pyright" -version = "1.1.362" +version = "1.1.364" requires_python = ">=3.7" summary = "Command line wrapper for pyright" groups = ["linting"] @@ -2702,8 +2702,8 @@ dependencies = [ "nodeenv>=1.6.0", ] files = [ - {file = "pyright-1.1.362-py3-none-any.whl", hash = "sha256:969957cff45154d8a45a4ab1dae5bdc8223d8bd3c64654fa608ab3194dfff319"}, - {file = "pyright-1.1.362.tar.gz", hash = "sha256:6a477e448d4a07a6a0eab58b2a15a1bbed031eb3169fa809edee79cca168d83a"}, + {file = "pyright-1.1.364-py3-none-any.whl", hash = "sha256:865f1e02873c5dc7427c95acf53659a118574010e6fb364e27e47ec5c46a9f26"}, + {file = "pyright-1.1.364.tar.gz", hash = "sha256:612a2106a4078ec57efc22b5620729e9bdf4a3c17caba013b534bd33f7d08e5a"}, ] [[package]] @@ -2727,7 +2727,7 @@ files = [ [[package]] name = "pytest-asyncio" -version = "0.23.6" +version = "0.23.7" requires_python = ">=3.8" summary = "Pytest support for asyncio" groups = ["test"] @@ -2735,8 +2735,8 @@ dependencies = [ "pytest<9,>=7.0.0", ] files = [ - {file = "pytest-asyncio-0.23.6.tar.gz", hash = "sha256:ffe523a89c1c222598c76856e76852b787504ddb72dd5d9b6617ffa8aa2cde5f"}, - {file = "pytest_asyncio-0.23.6-py3-none-any.whl", hash = "sha256:68516fdd1018ac57b846c9846b954f0393b26f094764a28c955eabb0536a4e8a"}, + {file = "pytest_asyncio-0.23.7-py3-none-any.whl", hash = "sha256:009b48127fbe44518a547bddd25611551b0e43ccdbf1e67d12479f569832c20b"}, + {file = "pytest_asyncio-0.23.7.tar.gz", hash = "sha256:5f5c72948f4c49e7db4f29f2521d4031f1c27f86e57b046126654083d4770268"}, ] [[package]] @@ -3303,18 +3303,18 @@ files = [ [[package]] name = "sphinx-click" -version = "5.1.0" +version = "6.0.0" requires_python = ">=3.8" summary = "Sphinx extension that automatically documents click applications" groups = ["docs"] dependencies = [ - "click>=7.0", + "click>=8.0", "docutils", - "sphinx>=2.0", + "sphinx>=4.0", ] files = [ - {file = "sphinx-click-5.1.0.tar.gz", hash = "sha256:6812c2db62d3fae71a4addbe5a8a0a16c97eb491f3cd63fe34b4ed7e07236f33"}, - {file = "sphinx_click-5.1.0-py3-none-any.whl", hash = "sha256:ae97557a4e9ec646045089326c3b90e026c58a45e083b8f35f17d5d6558d08a0"}, + {file = "sphinx_click-6.0.0-py3-none-any.whl", hash = "sha256:1e0a3c83bcb7c55497751b19d07ebe56b5d7b85eb76dd399cf9061b497adc317"}, + {file = "sphinx_click-6.0.0.tar.gz", hash = "sha256:f5d664321dc0c6622ff019f1e1c84e58ce0cecfddeb510e004cf60c2a3ab465b"}, ] [[package]] diff --git a/tests/integration/test_sqlquery_service.py b/tests/integration/test_sqlquery_service.py index e40a267e..e6f2af9f 100644 --- a/tests/integration/test_sqlquery_service.py +++ b/tests/integration/test_sqlquery_service.py @@ -142,7 +142,12 @@ async def test_async_fixture_and_query() -> None: repo = USStateAsyncRepository(session=session) query_service = SQLAlchemyAsyncQueryService(session=session) fixture = await open_fixture_async(fixture_path, USStateSyncRepository.model_type.__tablename__) # type: ignore[has-type] - _add_objs = await repo.add_many([USStateSyncRepository.model_type(**raw_obj) for raw_obj in fixture]) + _add_objs = await repo.add_many( + [ + USStateSyncRepository.model_type(**raw_obj) # pyright: ignore[reportGeneralTypeIssues] + for raw_obj in fixture + ], + ) query_count = await query_service.repository.count(statement=select(StateQuery)) assert query_count > 0 list_query_objs, list_query_count = await query_service.repository.list_and_count( diff --git a/tests/models_bigint.py b/tests/models_bigint.py index 126ceb2b..5fdd3b00 100644 --- a/tests/models_bigint.py +++ b/tests/models_bigint.py @@ -7,6 +7,7 @@ from sqlalchemy import Column, FetchedValue, ForeignKey, String, Table, func from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship +from sqlalchemy.orm.decl_base import _TableArgsType as TableArgsType # pyright: ignore[reportPrivateUsage] from advanced_alchemy.base import BigIntAuditBase, BigIntBase, SlugKey, merge_table_arguments from advanced_alchemy.repository import ( @@ -61,7 +62,7 @@ class BigIntSlugBook(BigIntBase, SlugKey): @declared_attr.directive @classmethod - def __table_args__(cls) -> dict | tuple: + def __table_args__(cls) -> TableArgsType: return merge_table_arguments( cls, table_args={"comment": "Slugbook"}, @@ -89,8 +90,8 @@ class BigIntModelWithFetchedValue(BigIntBase): bigint_item_tag = Table( "bigint_item_tag", BigIntBase.metadata, - Column("item_id", ForeignKey("big_int_item.id"), primary_key=True), - Column("tag_id", ForeignKey("big_int_tag.id"), primary_key=True), + Column("item_id", ForeignKey("big_int_item.id"), primary_key=True), # pyright: ignore + Column("tag_id", ForeignKey("big_int_tag.id"), primary_key=True), # pyright: ignore ) @@ -482,7 +483,7 @@ class SlugBookAsyncService(SQLAlchemyAsyncRepositoryService[BigIntSlugBook]): match_fields = ["title"] def __init__(self, **repo_kwargs: Any) -> None: - self.repository: SlugBookAsyncRepository = self.repository_type(**repo_kwargs) + self.repository: SlugBookAsyncRepository = self.repository_type(**repo_kwargs) # pyright: ignore async def to_model(self, data: BigIntSlugBook | dict[str, Any], operation: str | None = None) -> BigIntSlugBook: if isinstance(data, dict) and "slug" not in data and operation == "create": @@ -499,7 +500,7 @@ class SlugBookSyncService(SQLAlchemySyncRepositoryService[BigIntSlugBook]): match_fields = ["title"] def __init__(self, **repo_kwargs: Any) -> None: - self.repository: SlugBookSyncRepository = self.repository_type(**repo_kwargs) + self.repository: SlugBookSyncRepository = self.repository_type(**repo_kwargs) # pyright: ignore def to_model(self, data: BigIntSlugBook | dict[str, Any], operation: str | None = None) -> BigIntSlugBook: if isinstance(data, dict) and "slug" not in data and operation == "create": @@ -516,7 +517,7 @@ class SlugBookAsyncMockService(SQLAlchemyAsyncRepositoryService[BigIntSlugBook]) match_fields = ["title"] def __init__(self, **repo_kwargs: Any) -> None: - self.repository: SlugBookAsyncMockRepository = self.repository_type(**repo_kwargs) + self.repository: SlugBookAsyncMockRepository = self.repository_type(**repo_kwargs) # pyright: ignore async def to_model(self, data: BigIntSlugBook | dict[str, Any], operation: str | None = None) -> BigIntSlugBook: if isinstance(data, dict) and "slug" not in data and operation == "create": @@ -533,7 +534,7 @@ class SlugBookSyncMockService(SQLAlchemySyncRepositoryService[BigIntSlugBook]): match_fields = ["title"] def __init__(self, **repo_kwargs: Any) -> None: - self.repository: SlugBookSyncMockRepository = self.repository_type(**repo_kwargs) + self.repository: SlugBookSyncMockRepository = self.repository_type(**repo_kwargs) # pyright: ignore def to_model(self, data: BigIntSlugBook | dict[str, Any], operation: str | None = None) -> BigIntSlugBook: if isinstance(data, dict) and "slug" not in data and operation == "create":