Skip to content

Commit

Permalink
Use DeclarativeBase as base class
Browse files Browse the repository at this point in the history
mypy bug workaround no longer needed as we are no longer specifying a metaclass
  • Loading branch information
jdavcs committed Mar 8, 2024
1 parent e902ce8 commit 7ea1b84
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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


Expand All @@ -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
Expand Down

0 comments on commit 7ea1b84

Please sign in to comment.