From 8a8a422334b4e311eebe0eb22a7bb238d24e5969 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 b9a39445c696..4099f769f029 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -106,6 +106,7 @@ from sqlalchemy.orm import ( aliased, column_property, + DeclarativeBase, deferred, joinedload, Mapped, @@ -119,6 +120,7 @@ from sqlalchemy.orm.attributes import flag_modified from sqlalchemy.orm.collections import attribute_keyed_dict from sqlalchemy.sql import exists +from sqlalchemy.sql.expression import FromClause from typing_extensions import ( Literal, Protocol, @@ -224,23 +226,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 @@ -252,7 +246,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