From 634d251395eff8ae6f513195ea8843fd8b55b890 Mon Sep 17 00:00:00 2001 From: Yusur Princeps Date: Thu, 29 Jan 2026 19:15:48 +0100 Subject: [PATCH] 0.12.2 fix imports (again) --- CHANGELOG.md | 4 ++++ src/suou/__init__.py | 2 +- src/suou/sqlalchemy/__init__.py | 15 +++++---------- src/suou/sqlalchemy/asyncio.py | 21 ++++++++++++++------- src/suou/sqlalchemy/quart.py | 6 ++++++ 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c2490..c8e5b18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.12.2 + ++ Fix imports in module `sqlalchemy.quart` + ## 0.12.1 + Fix import failure for `AsyncSelectPagination` (module `sqlalchemy`) diff --git a/src/suou/__init__.py b/src/suou/__init__.py index 709b41d..b50bb02 100644 --- a/src/suou/__init__.py +++ b/src/suou/__init__.py @@ -38,7 +38,7 @@ from .http import WantsContentType from .color import OKLabColor, chalk, WebColor, RGBColor, LinearRGBColor, XYZColor, OKLCHColor from .mat import Matrix -__version__ = "0.12.1" +__version__ = "0.12.2" __all__ = ( 'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue', diff --git a/src/suou/sqlalchemy/__init__.py b/src/suou/sqlalchemy/__init__.py index 889d7ad..d46ca8f 100644 --- a/src/suou/sqlalchemy/__init__.py +++ b/src/suou/sqlalchemy/__init__.py @@ -18,19 +18,14 @@ from __future__ import annotations from abc import ABCMeta, abstractmethod from functools import wraps -from typing import Any, Callable, Iterable, Never, TypeVar -import warnings -from sqlalchemy import BigInteger, Boolean, CheckConstraint, Date, Dialect, ForeignKey, LargeBinary, Column, MetaData, SmallInteger, String, create_engine, select, text -from sqlalchemy.orm import DeclarativeBase, InstrumentedAttribute, Relationship, Session, declarative_base as _declarative_base, relationship +from typing import Callable, Iterable, Never, TypeVar +from sqlalchemy import LargeBinary, Column, create_engine, select +from sqlalchemy.orm import DeclarativeBase, Session from sqlalchemy.types import TypeEngine -from suou.glue import FakeModule -from ..snowflake import SnowflakeGen -from ..itertools import kwargs_prefix, makelist +from ..itertools import makelist from ..signing import HasSigner, UserSigner -from ..codecs import StringCase -from ..functools import deprecated, not_implemented -from ..iding import Siq, SiqGen, SiqType, SiqCache +from ..functools import deprecated from ..classtools import Incomplete, Wanted diff --git a/src/suou/sqlalchemy/asyncio.py b/src/suou/sqlalchemy/asyncio.py index e2bab47..b28f305 100644 --- a/src/suou/sqlalchemy/asyncio.py +++ b/src/suou/sqlalchemy/asyncio.py @@ -26,6 +26,10 @@ from sqlalchemy import Select, Table, func, select from sqlalchemy.orm import DeclarativeBase, lazyload from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine +try: + from .quart import AsyncSelectPagination +except ImportError: + AsyncSelectPagination = None from suou.exceptions import NotFoundError from suou.glue import glue @@ -103,13 +107,16 @@ class SQLAlchemy: Return a pagination. Analogous to flask_sqlalchemy.SQLAlchemy.paginate(). """ async with self as session: - return AsyncSelectPagination( - select = select, - session = session, - page = page, - per_page=per_page, max_per_page=max_per_page, - error_out=self.NotFound if error_out else None, count=count - ) + try: + return AsyncSelectPagination( + select = select, + session = session, + page = page, + per_page=per_page, max_per_page=max_per_page, + error_out=self.NotFound if error_out else None, count=count + ) + except Exception: + raise RuntimeError('Cannot paginate; required dependencies are not installed') async def create_all(self, *, checkfirst = True): """ Initialize database diff --git a/src/suou/sqlalchemy/quart.py b/src/suou/sqlalchemy/quart.py index e314f06..dd03f06 100644 --- a/src/suou/sqlalchemy/quart.py +++ b/src/suou/sqlalchemy/quart.py @@ -3,7 +3,13 @@ SQLAlchemy-Quart bindings """ +from select import select from flask_sqlalchemy.pagination import Pagination +from sqlalchemy import Select, func +from sqlalchemy.ext.asyncio import AsyncSession +from sqlalchemy.orm import lazyload + +from ..exceptions import NotFoundError class AsyncSelectPagination(Pagination):