From 7ea1b84d11e9460518cbcad8e615fcdbf203a3df Mon Sep 17 00:00:00 2001 From: John Davis Date: Fri, 8 Mar 2024 14:51:16 -0500 Subject: [PATCH] Use DeclarativeBase as base class mypy bug workaround no longer needed as we are no longer specifying a metaclass --- lib/galaxy/model/__init__.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index ed4e46607fd6..793c94a13e29 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -97,12 +97,14 @@ VARCHAR, ) from sqlalchemy.exc import OperationalError +from sqlalchemy.expression import FromClause from sqlalchemy.ext import hybrid from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.orderinglist import ordering_list from sqlalchemy.orm import ( aliased, column_property, + DeclarativeBase, deferred, joinedload, Mapped, @@ -221,23 +223,15 @@ if TYPE_CHECKING: - # Workaround for https://github.com/python/mypy/issues/14182 - from sqlalchemy.orm import DeclarativeMeta as _DeclarativeMeta - - class DeclarativeMeta(_DeclarativeMeta, type): - pass - from galaxy.datatypes.data import Data from galaxy.tools import DefaultToolState from galaxy.workflow.modules import WorkflowModule class _HasTable: - table: Table - __table__: Table + table: FromClause + __table__: FromClause else: - from sqlalchemy.orm import DeclarativeMeta - _HasTable = object @@ -249,7 +243,7 @@ def get_uuid(uuid: Optional[Union[UUID, str]] = None) -> UUID: return UUID(str(uuid)) -class Base(_HasTable, metaclass=DeclarativeMeta): +class Base(_HasTable, DeclarativeBase): __abstract__ = True metadata = MetaData(naming_convention=NAMING_CONVENTION) mapper_registry.metadata = metadata